Method: Pathname#files

Defined in:
lib/pleasant_path/pathname.rb

#filesArray<Pathname>

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

Examples:

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

Pathname.new("parent").files
  # == [
  #      Pathname.new("parent/file1"),
  #      Pathname.new("parent/file2")
  #    ]

Returns:

Raises:

  • (SystemCallError)

    if the Pathname does not point to an existing directory



182
183
184
# File 'lib/pleasant_path/pathname.rb', line 182

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