From: 7stud -- Date: 2008-02-20T08:37:18+09:00 Subject: Re: Is there any object-oriented File class in ruby ? 7stud -- wrote: > tom_33 wrote: >> I am very new to Ruby and my question is about trying to understand >> why Ruby is often described as a "pure object-oriented language", when >> the core library seems to be quite procedural. >> >> For example, the class File seems to have a big bunch of procedural >> functions (or static methods, or whatever you want to call them) that >> needs the filename to be provided as a parameter. >> >> The File class in java is a much better OO class for managing files: >> http://java.sun.com/j2se/1.5.0/docs/api/java/io/File.html >> than the following ruby class: >> http://ruby-doc.org/core/classes/File.html >> >> For example, the ruby method File.basename is documented as only >> supporting forward slashes, regardless of the local file system. >> File.basename("/home/gumby/work/ruby.rb") #=> "ruby.rb" >> Essentially, this seems to be not much more than a string parsing >> function with no OO abstraction that represents a file object. >> Compare this with doing the same thing with java: >> File f = new File("/home/gumby/work/ruby.rb"); // or new File("C:\\home >> \\gumby\\work\\ruby.rb"); >> f.getName() #=> "ruby.rb" >> >> Now my question is what have I been missing here ? >> I mean, is there any other much better File class somewhere in the >> Ruby core that is more pure OO, or otherwise why is a language with a >> CORE procedural "class" library described as being a pure oo >> language ? >> >> / Tom > I just wanted to add: there are many bad implementations in ruby. In addition, there are many bad programmers that badly implement ruby--check out just about any thread on this forum. A lot of solutions(most?) will string together 3 or 4 ruby method calls in a one liner with a couple of regex's sprinkled in for good measure. As far as I can tell, not many people know how to write clear efficient ruby code. Of course their battle cry is: ruby is so inefficient anyway, what does it matter if I write inefficient and obfuscated code. -- Posted via http://www.ruby-forum.com/.