Class: CIAT::TrafficLight
- Inherits:
-
Object
- Object
- CIAT::TrafficLight
- Defined in:
- lib/ciat/traffic_light.rb
Instance Attribute Summary collapse
-
#setting ⇒ Object
readonly
Returns the value of attribute setting.
Instance Method Summary collapse
- #color ⇒ Object
-
#green! ⇒ Object
:nodoc:.
- #green? ⇒ Boolean
-
#initialize(setting = :unset) ⇒ TrafficLight
constructor
:nodoc:.
-
#red! ⇒ Object
:nodoc:.
- #red? ⇒ Boolean
- #unset? ⇒ Boolean
-
#yellow! ⇒ Object
:nodoc:.
- #yellow? ⇒ Boolean
Constructor Details
#initialize(setting = :unset) ⇒ TrafficLight
:nodoc:
4 5 6 |
# File 'lib/ciat/traffic_light.rb', line 4 def initialize(setting = :unset) #:nodoc: @setting = setting end |
Instance Attribute Details
#setting ⇒ Object (readonly)
Returns the value of attribute setting.
2 3 4 |
# File 'lib/ciat/traffic_light.rb', line 2 def setting @setting end |
Instance Method Details
#color ⇒ Object
36 37 38 |
# File 'lib/ciat/traffic_light.rb', line 36 def color @setting.to_s end |
#green! ⇒ Object
:nodoc:
16 17 18 |
# File 'lib/ciat/traffic_light.rb', line 16 def green! #:nodoc: @setting = :green unless yellow? end |
#green? ⇒ Boolean
12 13 14 |
# File 'lib/ciat/traffic_light.rb', line 12 def green? @setting == :green end |
#red! ⇒ Object
:nodoc:
32 33 34 |
# File 'lib/ciat/traffic_light.rb', line 32 def red! #:nodoc: @setting = :red unless yellow? end |
#red? ⇒ Boolean
28 29 30 |
# File 'lib/ciat/traffic_light.rb', line 28 def red? @setting == :red end |
#unset? ⇒ Boolean
8 9 10 |
# File 'lib/ciat/traffic_light.rb', line 8 def unset? @setting == :unset end |
#yellow! ⇒ Object
:nodoc:
24 25 26 |
# File 'lib/ciat/traffic_light.rb', line 24 def yellow! #:nodoc: @setting = :yellow end |
#yellow? ⇒ Boolean
20 21 22 |
# File 'lib/ciat/traffic_light.rb', line 20 def yellow? @setting == :yellow end |