From: Newbie Date: 2007-02-14T04:12:20+09:00 Subject: Ruby, OO newb, subclassing question I am a Ruby, OO newbie. I mostly work with databases. I am trying to use ruby for scripting some of my routine tasks. I am trying to sub class a File, to create a HtmlReportFile with additional methods. class HtmlReport < File def initialize(filename) open(filename,'w') #Don't know why this does not return a file object end def header(title) html_head = <<-EOF_HTML_HEAD #{title} EOF_HTML_HEAD puts html_head #shouldn't this write to self(file)?? end def content(text) puts text end def footer puts '' close end end if $0 == __FILE__ my_report = HtmlReport.new('test.html') my_report.header('Test report') my_report.content('Some text') my_report.footer end But running the above returns the following error: c:\code\ruby\sample>ruby test2.rb test2.rb:11:in `write': uninitialized stream (IOError) from test2.rb:11:in `header' from test2.rb:28 Can somebody please tell me How it needs to be done. Thanks Saleo -- Posted via http://www.ruby-forum.com/.