Skip to content

Instantly share code, notes, and snippets.

@adparadise
Created December 8, 2011 17:49
Show Gist options
  • Save adparadise/1447798 to your computer and use it in GitHub Desktop.
Save adparadise/1447798 to your computer and use it in GitHub Desktop.
Simple directory recursion for pathnames
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