Skip to content

Instantly share code, notes, and snippets.

@jaysignorello
Created July 31, 2012 15:50
Show Gist options
  • Save jaysignorello/3217991 to your computer and use it in GitHub Desktop.
Save jaysignorello/3217991 to your computer and use it in GitHub Desktop.
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