Skip to content

Instantly share code, notes, and snippets.

@Kameshwaran
Created February 4, 2015 06:03
Show Gist options
  • Save Kameshwaran/e665b402cea38e76ae99 to your computer and use it in GitHub Desktop.
Save Kameshwaran/e665b402cea38e76ae99 to your computer and use it in GitHub Desktop.
Listing all the files recursively in a folder
def files(file)
return file unless ( file = Pathname.new(file) and File.directory?(file) )
file.children.map { |f| files(f) }
end
# files(".") => [#<Pathname:hello.rb>, #<Pathname:spec/hello.rb>, #<Pathname:spec/hai.rb>, ...]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment