From: Markus Arike Date: 2008-03-04T00:40:01+09:00 Subject: Re: Understanding ruby classes A possible implementation would be the Template Method pattern, which seems to fit your requirements perfectly. class PrintQueue def initialize @title = "My Wonderful Document" @text = "This is a report on the Ruby Programming Language" end def print_output print_start print_head @text.each do |line| print_line(line) end print_end end def print_start end def print_head print_line(@title) end def print_body_start end def print_line(line) raise "Called abstract method: print_line" end def print_body_end end def print_end end end class PrintHTML < PrintQueue def print_start puts '' end def print_head puts ' ' puts " #{@title}" puts ' ' end def print_body_start puts '' end def print_line(line) puts "

#{line}

" end def print_body_end puts('') end def print_end puts('') end end class PrintPDF < PrintQueue def print_start end def print_head puts "**** #{@title} ****" puts end def print_body_start end def print_line(line) puts line end def print_body_end end def print_end end end printjob = PrintHTML.new printjob.print_output printjob = PrintPDF.new printjob.print_output Markus Arike -- Posted via http://www.ruby-forum.com/.