Created
July 31, 2012 15:50
-
-
Save jaysignorello/3217991 to your computer and use it in GitHub Desktop.
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, text) | |
@title = title | |
@text = text | |
end | |
def output_format(format) | |
if format == :plain | |
puts "**#{@title}**" | |
elsif format == :html | |
puts "<html>" | |
puts " <head>" | |
puts " <title>#{@title}</title>" | |
puts " </head>" | |
puts "<body>" | |
else | |
raise "unknow format: #{format}" | |
end | |
@text.each do |line| | |
if format == :plain | |
puts line | |
elsif format == :html | |
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