Hello all (esp matz!)
I would like to know whether there is a good reason for the current design of
the File and Dir classes that use class methods for most of their operations,
the only reason I can think of is that for some reason it is more economical to
use strings for filenames rather than have a class that instanciates potential
files.
I always have this nagging feeling that I am doing too much work when handling
lists of files since Dir.entries returns a list of filenames that need to be
reunited with their directory path to be useful.
I would like some insight on this issue before I go and implement my preferred
alternative which is as follows.
Have a FileSpec, DirSpec, UrlSpec classes whose instances specify a potential
directory/file or url, whether it exists or not.
'/usr/aDirectory'.fileSpec.exists?
'/usr/aDirectory'.fileSpec.directory?
'/usr/aDirectory'.fileSpec.fileEntries { | fileSpec | fileSpec.open { | file
| file each { | line | puts line} } }
fs = '/usr/aDirectory/aFile'.fileSpec
fs.touch unless fs.exists?
thanks in advance
Keith