Created
July 28, 2010 00:26
-
-
Save bnadlerjr/493108 to your computer and use it in GitHub Desktop.
This file contains 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
HTMLFormatter = lambda { |data| "<p>#{data}</p>" } | |
TextFormatter = lambda { |data| data } | |
PDFFormatter = lambda { |data| "<pdf>#{data}</pdf" } | |
def output(data, format) | |
case format | |
when :html | |
return HTMLFormatter.call(data) | |
when :text | |
return TextFormatter.call(data) | |
when :pdf | |
return PDFFormatter.call(data) | |
else | |
raise ArgumentError, "Invalid format (#{format})." | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment