method
each_entry
each_entry()
public
Register or
log in
to add new notes.
snej -
December 23, 2008
0 thanks
Entries are not standalone!
The entry Pathnames consist solely of leaf filenames, so they’re not directly useable in filesystem operations like “open” or “directory?”. To create a useable Pathname, append the entry onto the directory you’re iterating over.
Also keep in mind that the iteration includes the magic entries “.” and “..”, which you probably want to skip. (Is this true on Windows too?)
The #children method doesn’t have either of these issues, although it’s slightly less efficient since it creates an Array of Pathnames up-front instead of yielding one at a time.