class Thermostat

Attributes

airco[RW]
current_value[RW]
heating[RW]
range[RW]
wanted_value[RW]

Public Class Methods

new(current_value = 0, wanted_value = 0, range = 0) click to toggle source
# File lib/thermostat.rb, line 8
def initialize(current_value = 0, wanted_value = 0, range = 0)
  @current_value = current_value
  @wanted_value = wanted_value
  @range = range
end

Public Instance Methods

check() click to toggle source
# File lib/thermostat.rb, line 14
def check
  if @current_value < @wanted_value - @range
    heat
  elsif @current_value > @wanted_value + @range
    cool
  else
    normal
  end
end
cool() click to toggle source
# File lib/thermostat.rb, line 24
def cool
  @airco = true
  @heating = false
end
heat() click to toggle source
# File lib/thermostat.rb, line 29
def heat
  @airco = false
  @heating = true
end
normal() click to toggle source
# File lib/thermostat.rb, line 34
def normal
  @airco = false
  @heating = false
end