Created
November 2, 2010 11:23
-
-
Save cheeyeo/659501 to your computer and use it in GitHub Desktop.
First implementation of the Report class
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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