class Thermostat
Attributes
cooling[R]
heating[R]
Public Class Methods
new()
click to toggle source
# File lib/thermostat.rb, line 5 def initialize @cooling = false @heating = false end
Public Instance Methods
control_climate(temperature, ideal_temperature, range)
click to toggle source
Checks if climate control needs to bee enabled. control_climate
(temperature, ideal_temperature, range) example: control_climate
(20, 18, 1)
# File lib/thermostat.rb, line 13 def control_climate (temperature, ideal_temperature, range) if temperature <= (ideal_temperature - range) @heating = true @cooling = false elsif temperature >= (ideal_temperature + range) @heating = false @cooling = true else @heating = false @cooling = false end end
get_climate_control_state()
click to toggle source
# File lib/thermostat.rb, line 26 def get_climate_control_state if @heating return "Heating is enabled" elsif @cooling return "Cooling is enabled" else return "Cooling and heating are disabled" end end