From: Tanaka Akira Date: 2005-08-25T15:50:47+09:00 Subject: Re: Pathname#walk for traversing path nodes (patch) In article <430BB56D.8010506@magical-cat.org>, ES writes: >> It seems that Pathname#walk doesn't yield the root directory. >> Is it intended? How useful/unuseful with this behavior? I'd like to hear your usage of Pathname#walk. I want to know at least one usage of the method before I introduce it to pathname.rb. > def walk() > @path.scan(%r{[^/]*/?})[0...-1].inject('') do |path, dir| > yield Pathname.new(path << dir) > path > end > end # walk() It has a problem with non-canonical paths. % ruby -rlib/pathname.rb -e 'Pathname.new("a//b").walk {|v| p v }' # # # I think it should use Pathname#dirname like my version in [ruby-core:5641]. % ruby -rlib/pathname.rb -e 'Pathname.new("a//b").walk2 {|v| p v }' # # -- Tanaka Akira