Skip to content

Instantly share code, notes, and snippets.

@cheeyeo
Created November 2, 2010 11:23
Show Gist options
  • Save cheeyeo/659501 to your computer and use it in GitHub Desktop.
Save cheeyeo/659501 to your computer and use it in GitHub Desktop.
First implementation of the Report class
class Report
def initialize
@title = 'Monthly Report'
@text = ['Things are going', 'really, really well.']
end
def output_report(format)
if format == :plain
puts("*** #{@title} ***")
elsif format == :html
puts('<html>')
puts(' <head>')
puts(" <title>#{@title}</title>")
puts(' </head>')
puts(' <body>')
else
raise "Unknown format: #{format}"
end
@text.each do |line|
if format == :plain
puts(line)
else
puts(" <p>#{line}</p>" )
end
end
if format == :html
puts(' </body>')
puts('</html>')
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment