Skip to content

Instantly share code, notes, and snippets.

@kurotaky
Created November 8, 2012 22:45
Show Gist options
  • Save kurotaky/4042351 to your computer and use it in GitHub Desktop.
Save kurotaky/4042351 to your computer and use it in GitHub Desktop.
Formatter
class Formatter
def output_report(title, text)
raise 'Abstruct method called'
end
end
class HTMLFormatter < Formatter
def output_report(title, text)
puts '<html>'
puts '<head>'
puts '<title#{title}</title>'
puts '</head>'
puts '<body>'
text.each do |line|
puts " <p>#{line}</p>"
end
puts '</body>'
puts '</html>'
end
end
class PlainTextFormatter < Formatter
def output_report(title, text)
puts("***** #{title} *****")
text.each do |line|
puts(line)
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment