class Formats
Public Class Methods
new(ary)
click to toggle source
# File lib/fizzbuzz_aj/formats.rb, line 3 def initialize ary @ary = ary end
Public Instance Methods
as_html()
click to toggle source
# File lib/fizzbuzz_aj/formats.rb, line 25 def as_html <<-EOF <ul> #{@ary.map { |d| "<li>#{d}</li>"}.join("\n\t")} </ul> EOF end
as_json()
click to toggle source
# File lib/fizzbuzz_aj/formats.rb, line 21 def as_json @ary.to_json end
as_plain()
click to toggle source
# File lib/fizzbuzz_aj/formats.rb, line 17 def as_plain @ary.join(", ") end
format_as(fmt)
click to toggle source
# File lib/fizzbuzz_aj/formats.rb, line 7 def format_as fmt if(fmt == "html") as_html elseif (fmt == "json") as_json else as_plain end end