Created
January 24, 2013 21:10
-
-
Save DavidBechtel/4627780 to your computer and use it in GitHub Desktop.
presents as a single responsibility class
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
require "json" | |
class Presents < Struct.new(:ary) | |
def as_text | |
ary.each do |line| | |
puts line | |
end | |
end | |
def as_json | |
JSON.generate(ary) | |
end | |
def as_html | |
htm = "<ul>\n" | |
ary.each do |line| | |
htm += " <li> #{line} </li> \n" | |
end | |
htm = htm += "</ul>" | |
htm | |
end | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment