Class: LightMeUp::Light

Inherits:
Object
  • Object
show all
Defined in:
lib/light_me_up/light.rb

Constant Summary collapse

BRIGHTNESS_RANGE =
(0..100).freeze
TEMPERATURE_RANGE =
(0..100).freeze

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(on: nil, brightness: nil, temperature: nil) ⇒ Light

Returns a new instance of Light.



28
29
30
31
32
33
34
35
# File 'lib/light_me_up/light.rb', line 28

def initialize(on: nil, brightness: nil, temperature: nil)
  validate_brightness(brightness)
  validate_temperature(temperature)

  @on = on
  @brightness = brightness
  @temperature = temperature
end

Instance Attribute Details

#brightnessObject (readonly)

Returns the value of attribute brightness.



5
6
7
# File 'lib/light_me_up/light.rb', line 5

def brightness
  @brightness
end

#onObject (readonly)

Returns the value of attribute on.



5
6
7
# File 'lib/light_me_up/light.rb', line 5

def on
  @on
end

#temperatureObject (readonly)

Returns the value of attribute temperature.



5
6
7
# File 'lib/light_me_up/light.rb', line 5

def temperature
  @temperature
end

Class Method Details

.max_brightnessObject



11
12
13
# File 'lib/light_me_up/light.rb', line 11

def max_brightness
  BRIGHTNESS_RANGE.last
end

.max_temperatureObject



19
20
21
# File 'lib/light_me_up/light.rb', line 19

def max_temperature
  TEMPERATURE_RANGE.last
end

.min_brightnessObject



15
16
17
# File 'lib/light_me_up/light.rb', line 15

def min_brightness
  BRIGHTNESS_RANGE.first
end

.min_temperatureObject



23
24
25
# File 'lib/light_me_up/light.rb', line 23

def min_temperature
  TEMPERATURE_RANGE.first
end