Skip to content

Instantly share code, notes, and snippets.

@DavidBechtel
Created January 24, 2013 21:10
Show Gist options
  • Save DavidBechtel/4627780 to your computer and use it in GitHub Desktop.
Save DavidBechtel/4627780 to your computer and use it in GitHub Desktop.
presents as a single responsibility class
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