Here is a patch that adds the functionality as outlined by Alexander. It's using "Pathname#join" to build the glob pattern, and then delegating to "Pathname.glob".
As described in the rdoc, it will accept a single string with a glob pattern, or an array of glob patterns.
The main use case is when you want to do something based relative to a current directory that is already available as Pathname, such as Rails.root in a Rails project. With this, you can say e.g.
It seems the proposed implementation treats the receiver as a glob pattern.
% ruby -rpathname -e '
class Pathname
def glob(pattern, flags = 0, &b)
Array(pattern).flat_map do |pat|
self.class.glob(join(pat), flags, &b)
end
end
end
p Pathname("/b*").glob("i*")
'
[#<Pathname:/boot/initrd.img-3.16.0-4-amd64>, #<Pathname:/bin/ip>]
We looked at this issue at today's developer meeting. As Akira already respond, the proposed patch has a problem. In order to reroute that we need to extend Dir.glob. Nobu opened a ticker for that. Once he finished that, we can resume this one.