Method: Pathname#dirs

Defined in:
lib/pleasant_path/pathname.rb

#dirsArray<Pathname>

Returns the direct child directories of the directory indicated by the Pathname. Returned Pathnames are prefixed by the original Pathname.

Examples:

FileUtils.mkdir("parent")
FileUtils.mkdir("parent/dir1")
FileUtils.mkdir("parent/dir1/dir1")
FileUtils.mkdir("parent/dir2")
FileUtils.touch("parent/file1")

Pathname.new("parent").dirs
  # == [
  #      Pathname.new("parent/dir1"),
  #      Pathname.new("parent/dir2")
  #    ]

Returns:

Raises:

  • (SystemCallError)

    if the Pathname does not point to an existing directory



106
107
108
# File 'lib/pleasant_path/pathname.rb', line 106

def dirs
  self.children.tap{|c| c.select!(&:dir?) }
end