Is there a better way than below? (Note: I don't want to implement realpath et al myself :-).
require 'pathname'
def realpath(p)
Pathname.new(p).realpath
end
def basename(p)
Pathname.new(p).basename
end
def dirname(p)
Pathname.new(p).dirname
end
Regards,
dave
David Garamond wrote:
Is there a better way than below? (Note: I don't want to implement realpath et al myself :-).
[snip]
Pathname.new(p).realpath
Pathname.new(p).basename
Pathname.new(p).dirname
Sorry, that should've been:
Pathname.new(p).realpath.to_s
Pathname.new(p).basename.to_s
Pathname.new(p).dirname.to_s
Regards,
dave
For basename and dirname:
File.basename(p)
File.dirname(p)
Dunno for realpath 
- Jamis
···
On 12:32 Sat 25 Dec , David Garamond wrote:
Is there a better way than below? (Note: I don't want to implement
realpath et al myself :-).
require 'pathname'
def realpath(p)
Pathname.new(p).realpath
end
def basename(p)
Pathname.new(p).basename
end
def dirname(p)
Pathname.new(p).dirname
end
Regards,
dave
--
Jamis Buck
jgb3@email.byu.edu
http://www.jamisbuck.org/jamis
Hi,
Pathname.new(p).basename.to_s
Pathname.new(p).dirname.to_s
File.basename(p)
File.dirname(p)
Pathname.new(p).realpath.to_s
File.expand_path(p), though it doesn't follow links. The #realpath implementation in pathname.rb does the resolving by itself, so it seems you have to make your own function :I
-Ilmari
···
On 25.12.2004, at 06:33, David Garamond wrote: