From: Niklas Frykholm Date: 2001-10-27T19:46:56+09:00 Subject: [ruby-talk:23613] Re: FileSpec vs Dir/File class methods [Keith Hodges]: > 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. Because a File object refers to an open file, not to a path name. I believe, that what you really want ;) is a Path class. > '/usr/aDirectory'.fileSpec.exists? With a Path class that would be (for example): p = Path.new('/usr/aDirectory') p.exists? >> true p[0] >> '/' p[1] >> 'usr' p.length >> 3 p.directory? >> true A Path class might make it easier to deal with some things, such as different path separators on different systems. On the other hand it would complicate the language (more to learn). The File methods would have to be changed to take both a string or a path. Personally, I'm quite happy with having paths as Strings. If you really need Path objects, you can write a class for them (and post it to RAA ;). // Niklas