class Thermostat

Simulates a simple thermostat

Attributes

temperature[RW]

Public Class Methods

new(**args) click to toggle source

Initialises the Thermostat class @param temperature [temperature] the starting thermostat temperature

# File lib/thermostat.rb, line 7
def initialize(**args)
  @temperature = args[:temperature] || 0
end

Public Instance Methods

cooling(args) click to toggle source

Cools down the thermostat @param value [value] the decrease in temperature

# File lib/thermostat.rb, line 19
def cooling(args)
  self.temperature -= args[:value]
end
heating(args) click to toggle source

Heats up the thermostat @param value [value] the increase in temperature

# File lib/thermostat.rb, line 13
def heating(args)
  self.temperature += args[:value]
end