instance method
Pathname#find
(?ignore_error: ::boolish) { (::Pathname) -> untyped } -> nil
(?ignore_error: ::boolish) -> ::Enumerator[::Pathname, nil]
find(ignore_error: true) { |pathname| ... }
lib/pathname.rb
View on GitHub ↗
# File tmp/rubies/ruby-4.0.0/lib/pathname.rb, line 30
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
Iterates over the directory tree in a depth first manner, yielding a Pathname for each file under “this” directory.
Note that you need to require ‘pathname’ to use this method.
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