A very simple Ruby way for listing files in a directory is the glob function:
1 2 3 4 5 6 7 8 | |
To avoid the separate each block, select could be used to iterate over the results. Used below with entries instead of glob.
Dir.entries(@directory_to_list).select do |f|
puts f
end
NB Dir.glob takes a pattern as an argument, Dir.entries takes a path.