Robert Klemme
10/27/2003 8:55:00 AM
"Carl Youngblood" <carl@ycs.biz> schrieb im Newsbeitrag
news:93Hmb.31810$HS4.118694@attbi_s01...
> You're right. I just tested it on my own box, which runs Ruby 1.8.0.
> Unfortunately, the lab machines in my university's computer science
> department are the things we are running this code on, and they are
> running ruby 1.6.8 (2002-12-24) [i386-linux-gnu]. The sysadmins don't
> want to upgrade to 1.8.0 because a lot of other packages would need to
> be upgraded as well. There's nothing more frustrating than not being
> able to take advantage of improvements in software just because
> somebody's running an older version!
That's easily fixed in your case:
class Dir
class << self
alias __mkdir__ mkdir
def mkdir(dir)
__mkdir__(dir.to_s)
end
end
end
However, I wouldn't regard it as too big an disadvantage if you had to do
Dir.mkdir( path.to_s ). Another option is to let Path inherit String:
class Path < String
def initialize(pathstring)
super(pathstring)
end
end
Or use String directly, since you can always manipulate file name strings
with File.split, File.join, File.dirname, File.basename, File.expand_path
and paths with String.split(File::PATH_SEPARATOR).
Kind regards
robert