method
entries
v1_8_6_287 -
Show latest stable
- Class:
Dir
entries(p1)public
Returns an array containing all of the filenames in the given directory. Will raise a SystemCallError if the named directory doesn’t exist.
Dir.entries("testdir") #=> [".", "..", "config.h", "main.rb"]
1Note
For specific entries, use Dir.glob
When working with the contents of a directory it's not uncommon to be interested in a specific subset of the entries present.
Dir.glob can be used to fetch entries by name and File.stat can be used to determine the type of file.