Method: Pathname#find
- Defined in:
- lib/rubysl/pathname/pathname.rb
#find(&block) ⇒ Object
Pathname#find is an iterator to traverse a directory tree in a depth first manner. It yields a Pathname 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 traverse.
If self is ., yielded pathnames begin with a filename in the current directory, not ./.
998 999 1000 1001 1002 1003 1004 1005 1006 |
# File 'lib/rubysl/pathname/pathname.rb', line 998 def find(&block) # :yield: pathname return to_enum(__method__) unless block_given? require 'find' if @path == '.' Find.find(@path) {|f| yield self.class.new(f.sub(%r{\A\./}, '')) } else Find.find(@path) {|f| yield self.class.new(f) } end end |