Created
December 8, 2011 17:49
-
-
Save adparadise/1447798 to your computer and use it in GitHub Desktop.
Simple directory recursion for pathnames
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
require 'pathname' | |
def each_recursive(dirpath, &block) | |
dirpath.each_entry do |entry| | |
next if "." == entry.to_s || ".." == entry.to_s | |
entry_path = dirpath + entry | |
if entry_path.directory? | |
each_recursive(entry_path, &block) | |
else | |
block.call(entry_path) | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment