class Json
Attributes
opt[R]
temperature[R]
Public Class Methods
new(temperature,opt)
click to toggle source
Constructor that it passes by parameter the hash opt and a value to calculate the temperature that the hash opt to include (temperature)
# File lib/json.rb, line 5 def initialize(temperature,opt) @temperature=temperature @opt=opt end
Public Instance Methods
print()
click to toggle source
Method to print in format JSON the temperature that the hash opt to include.
# File lib/json.rb, line 10 def print puts '{"Temperatures":' puts ' {' puts ' "Celsius": '+ temperature.to_celsius.to_s+','if opt[:celsius] puts ' "Fahrenheit": ' + temperature.to_fahrenheit.to_s + ','if opt[:fahrenheit] puts ' "Kelvin": ' + temperature.to_kelvin.to_s if opt[:kelvin] puts ' }' puts '}' end