class TemperaturePrinter
Attributes
temp[R]
Public Class Methods
print(temperature)
click to toggle source
# File lib/temperature_printer.rb, line 29 def self.print(temperature) puts 'TEXTing' puts to_text(@converter) puts '' puts 'HTMLing' puts to_html(@converter) puts '' puts 'JSONing' puts to_json(@converter) puts '' end
to_html(temperature)
click to toggle source
# File lib/temperature_printer.rb, line 17 def self.to_html(temperature) "<div>\n" + "<div>#{temperature.to_celcius} °C</div>\n" + "<div>#{temperature.to_fahrenheit} °F</div>\n" + "<div>#{temperature.to_kelvin} K</div>\n" + "</div>" end
to_json(temperature)
click to toggle source
# File lib/temperature_printer.rb, line 25 def self.to_json(temperature) "{\"celcius: #{temperature.to_celcius}\"; \"fahrenheit: #{temperature.to_fahrenheit}\"; \"kelvin: #{temperature.to_kelvin}\"}" end
to_text(temperature)
click to toggle source
# File lib/temperature_printer.rb, line 10 def self.to_text(temperature) "Temperature\n" + "#{temperature.to_celcius} °C\n" + "#{temperature.to_fahrenheit} °F\n" + "#{temperature.to_kelvin} K\n" end