Created
November 8, 2012 22:45
-
-
Save kurotaky/4042351 to your computer and use it in GitHub Desktop.
Formatter
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 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