Preview Ruby 4.1 is a preview. It can change before the final release. Switch to Ruby 4.0 →
instance method
Pathname#descend
() { (::Pathname) -> untyped } -> nil
() -> ::Enumerator[::Pathname, nil]
descend {|entry| ... } → nil
descend → new_enumerator
pathname_builtin.rb
View on GitHub ↗
# File tmp/rubies/ruby-4.1.0-preview1/pathname_builtin.rb, line 813
def descend
return to_enum(__method__) unless block_given?
vs = []
ascend {|v| vs << v }
vs.reverse_each {|v| yield v }
nil
end
With a block given, yields a new pathname for each successive dirname in the stored path; see File.dirname:
Example
# Absolute path. Pathname('/path/to/some/file.rb').descend {|pn| p pn } # #<Pathname:/> # #<Pathname:/path> # #<Pathname:/path/to> # #<Pathname:/path/to/some> # #<Pathname:/path/to/some/file.rb> # Relative path. Pathname('path/to/some/file.rb').descend {|pn| p pn } # #<Pathname:path> # #<Pathname:path/to> # #<Pathname:path/to/some> # #<Pathname:path/to/some/file.rb>
With no block given, returns a new Enumerator.