Skip to content

Instantly share code, notes, and snippets.

@havenwood

havenwood/dir.rb Secret

Created August 5, 2019 20:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save havenwood/1a81eef6932aa8e0e02064208722a01a to your computer and use it in GitHub Desktop.
Save havenwood/1a81eef6932aa8e0e02064208722a01a to your computer and use it in GitHub Desktop.
Example of Find.find for CableNinja on IRC
require 'find'
class Dir
def self.entries_r(dirname)
entries = []
Find.find dirname do |path|
if File.directory?(path)
# Do not traverse dotfile directories.
Find.prune if File.basename(File.expand_path(path)).start_with?('.')
next
else
entries << path
end
end
entries
end
end
Dir.entries_r '.'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment