From: Claudio Greco Date: 2008-10-03T16:54:00+09:00 Subject: Re: pathname's each_entry Sean O'halpin wrote: > It appears that each_entry yields just the basename, without any > context. You're right. require 'pathname' p = Pathname.new('C:/') # the same issue happens in Ubuntu p.each_entry { | x | puts x.expand_path } This code does not expand the path by prepending C:/, which I think would be the wanted behavior: it prepends the current working directory. In order to get my working directory I have to code as follows: require 'pathname' p = Pathname.new('C:/') p.each_entry { | x | puts x.expand_path('C:/') } So I've had a look at the source code for Pathname and each_entry, and whenever each_entry iterates over the file system objects (located within p in my case), the entry x is initialized simply with the name (in this case the name of the file within C:/) and the link with C:/ is lost forever, so while p knows about C:/, x does not. The problem I think is that each_entry is implemented as: def each_entry(&block) Dir.foreach(@path) {|f| yield self.class.new(f) } end while I would prefer the following: def each_entry(&block) Dir.foreach(@path) {|f| yield self.class.new(@path+f) } end Thanks, Claudio -- Posted via http://www.ruby-forum.com/.