ramalho@gmail.com
2/13/2007 7:40:00 PM
On 2/13/07, Newbie <saleo@bellsouth.net> wrote:
> def initialize(filename)
> open(filename,'w') #Don't know why this does not return a file object
> end
It does return a file, but you don't do anything with it... initialize
is not used to create an instance, but only to initialize de
attributes of an instance created by Ruby when you invoke
HtmlReport.new. So you'd have to assign the opened file to an instance
variable of your classe to avoid loosing the reference to it.
But the problem is deeper than that. I would not want to subclass
File. Subclassing is cool and very attractive when you first study OO,
but it's not the right solution in many cases.
Cheers,
Luciano