Created
February 4, 2015 06:03
-
-
Save Kameshwaran/e665b402cea38e76ae99 to your computer and use it in GitHub Desktop.
Listing all the files recursively in a folder
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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