Method: Pathname#descend

Defined in:
lib/pathname.rb

#descendObject

Iterates over and yields a new Pathname object for each element in the given path in descending order.

Pathname.new('/path/to/some/file.rb').descend {|v| p v}
   #<Pathname:/>
   #<Pathname:/path>
   #<Pathname:/path/to>
   #<Pathname:/path/to/some>
   #<Pathname:/path/to/some/file.rb>

Pathname.new('path/to/some/file.rb').descend {|v| p v}
   #<Pathname:path>
   #<Pathname:path/to>
   #<Pathname:path/to/some>
   #<Pathname:path/to/some/file.rb>

It doesn’t access the filesystem.



285
286
287
288
289
290
# File 'lib/pathname.rb', line 285

def descend
  vs = []
  ascend {|v| vs << v }
  vs.reverse_each {|v| yield v }
  nil
end