Class: CIAT::TrafficLight

Inherits:
Object
  • Object
show all
Defined in:
lib/ciat/traffic_light.rb

Constant Summary collapse

GREEN =
CIAT::TrafficLight.new(:green)
RED =
CIAT::TrafficLight.new(:red)
YELLOW =
CIAT::TrafficLight.new(:yellow)
UNSET =
CIAT::TrafficLight.new(:unset)
UNNEEDED =
CIAT::TrafficLight.new(:unneeded)

Instance Method Summary collapse

Constructor Details

#initialize(setting) ⇒ TrafficLight

:nodoc:



3
4
5
# File 'lib/ciat/traffic_light.rb', line 3

def initialize(setting) #:nodoc:
  @setting = setting
end

Instance Method Details

#colorObject



33
34
35
# File 'lib/ciat/traffic_light.rb', line 33

def color
  @setting.to_s
end

#green?Boolean

Returns:

  • (Boolean)


17
18
19
# File 'lib/ciat/traffic_light.rb', line 17

def green?
  @setting == :green
end

#red?Boolean

Returns:

  • (Boolean)


25
26
27
# File 'lib/ciat/traffic_light.rb', line 25

def red?
  @setting == :red
end

#unneeded?Boolean

Returns:

  • (Boolean)


29
30
31
# File 'lib/ciat/traffic_light.rb', line 29

def unneeded?
  @setting == :unneeded
end

#unset?Boolean

Returns:

  • (Boolean)


13
14
15
# File 'lib/ciat/traffic_light.rb', line 13

def unset?
  @setting == :unset
end

#yellow?Boolean

Returns:

  • (Boolean)


21
22
23
# File 'lib/ciat/traffic_light.rb', line 21

def yellow?
  @setting == :yellow
end