Ruby 2.1.0 リファレンスマニュアル > ライブラリ一覧 > pathnameライブラリ > Pathnameクラス > ascend
ascend {|pathname| ... } -> nil[permalink][rdoc]self のパス名から親方向に辿っていったときの各パス名を新しい Pathname オ ブジェクトとして生成し、ブロックへの引数として渡して実行します。
require 'pathname'
Pathname.new('/path/to/some/file.rb').ascend {|v| p v}
   #<Pathname:/path/to/some/file.rb>
   #<Pathname:/path/to/some>
   #<Pathname:/path/to>
   #<Pathname:/path>
   #<Pathname:/>
Pathname.new('path/to/some/file.rb').ascend {|v| p v}
   #<Pathname:path/to/some/file.rb>
   #<Pathname:path/to/some>
   #<Pathname:path/to>
   #<Pathname:path>
ファイルシステムにはアクセスしません。