Method: Pathname#find
- Defined in:
- lib/pathname.rb
#find(ignore_error: true) ⇒ Object
Iterates over the directory tree in a depth first manner, yielding a Pathname for each file under “this” directory.
Returns an Enumerator if no block is given.
Since it is implemented by the standard library module Find, Find.prune can be used to control the traversal.
If self is ., yielded pathnames begin with a filename in the current directory, not ./.
See Find.find
571 572 573 574 575 576 577 578 579 |
# File 'lib/pathname.rb', line 571 def find(ignore_error: true) # :yield: pathname return to_enum(__method__, ignore_error: ignore_error) unless block_given? require 'find' if @path == '.' Find.find(@path, ignore_error: ignore_error) {|f| yield self.class.new(f.delete_prefix('./')) } else Find.find(@path, ignore_error: ignore_error) {|f| yield self.class.new(f) } end end |