class JSONThermostat

Public Class Methods

new(json) click to toggle source
# File lib/json_thermostat.rb, line 6
def initialize(json)
  @value = JSON.parse(json)
end

Public Instance Methods

converten() click to toggle source
# File lib/json_thermostat.rb, line 18
def converten
  cur = ConvertTemp.new @jsonvalue['temperature'], @jsonvalue['unit']
  wan = ConvertTemp.new @value['temperature'], @value['unit']
  ran = ConvertTemp.new @value['range'], @value['unit']
  thermostat = Thermostat.new(cur.conv(@uni), wan.conv(@uni), ran.conv(@uni))
  thermostat.state
end
update(json) click to toggle source
# File lib/json_thermostat.rb, line 10
def update(json)
  @jsonvalue = JSON.parse(json)
  @jsonvalue['unit'] = 'celsius' if @jsonvalue['unit'].nil?
  @value['unit'] = 'celsius' if @value['unit'].nil?
  @uni = @value['unit']
  converten
end