This is what works for me:
Dir.entries(dir).select { |f| File.file?(File.join(dir, f)) }
Dir.entries
returns an array of strings. Then, we have to provide a full path of the file to File.file?
, unless dir
is equal to our current working directory. That's why this File.join()
.