Class: JsonPrinter

Inherits:
Object
  • Object
show all
Defined in:
lib/printer/json_printer.rb

Instance Method Summary collapse

Constructor Details

#initialize(temperature) ⇒ JsonPrinter

Returns a new instance of JsonPrinter.



3
4
5
# File 'lib/printer/json_printer.rb', line 3

def initialize(temperature)
    @temperature = temperature
end

Instance Method Details



7
8
9
10
11
12
13
# File 'lib/printer/json_printer.rb', line 7

def print
    "{"\
        "celsius: #{@temperature.to_celsius}, "\
        "fahrenheit: #{@temperature.to_fahrenheit}, "\
        "kelvin: #{@temperature.to_kelvin}"\
    "}"
end