Method: Path#find

Defined in:
lib/path/find.rb

#find {|path| ... } ⇒ Object

Path#find is an iterator to traverse a directory tree in a depth first manner. It yields a Path for each file under “this” directory.

Returns an enumerator if no block is given.

Since it is implemented by find.rb, Find.prune can be used to control the traversal.

If self is ., yielded paths begin with a filename in the current directory, not ./.

Yield Parameters:



14
15
16
17
18
19
20
21
22
# File 'lib/path/find.rb', line 14

def find
  return to_enum(__method__) unless block_given?
  require 'find'
  if @path == '.'
    Find.find(@path) { |f| yield Path.new(f.sub(%r{\A\./}, '')) }
  else
    Find.find(@path) { |f| yield Path.new(f) }
  end
end