Class: Dir
- Inherits:
-
Object
- Object
- Dir
- Defined in:
- lib/tankobon/ext/dir.rb
Class Method Summary collapse
Class Method Details
.empty?(dir) ⇒ Boolean
15 16 17 18 |
# File 'lib/tankobon/ext/dir.rb', line 15 def self.empty?(dir) entries = Dir.entries(dir) entries.length < 3 and entries.include? '.' and entries.include? '..' end |
.xplore(dir, &block) ⇒ Object
2 3 4 5 6 7 8 9 10 11 12 13 |
# File 'lib/tankobon/ext/dir.rb', line 2 def self.xplore(dir, &block) block = Proc.new {|f| puts "got: #{f}"} if block.nil? Dir.foreach(dir) do |f| next if f[0] == '.' if File.directory? File.join(dir, f) Dir.xplore(File.join(dir, f), &block) block.call(File.join(dir, f)) else block.call(File.join(dir, f)) end end end |