Feature #7360

Adding Pathname#glob

Added by Alexander E. Fischer about 3 years ago. Updated 2 months ago.

Assignee:Akira Tanaka


Currently there is only a Pathname.glob method, which allows you to find Pathname objects by a pattern including wildcard characters like '*'.

I would like to be able to use this relative to a current Pathname.

some_directory = Pathname.new('some_directory')
Pathname.glob(some_directory + 'a*') # all children starting with "a"

could then simply be:

some_directory.glob('a*') # all children starting with "a"

If you like the idea, please let me know. I will provide a patch then.

19c4ae36aaea65b30e8b73c89f7ac42bd6905ed7.patch Magnifier (2.84 KB) Tilmann Singer, 09/26/2015 04:51 PM

Related issues

Related to Ruby trunk - Feature #7378: Adding Pathname#write Closed 06/02/2012


#1 Updated by Yusuke Endoh about 3 years ago

  • Status changed from Open to Assigned
  • Assignee set to Akira Tanaka
  • Target version set to next minor

#2 Updated by Tilmann Singer 2 months ago

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.


to find all ruby files in the current project.

Link to the branch of my fork on GitHub:


Also available in: Atom PDF