Class: Switchbox
- Inherits:
-
Object
- Object
- Switchbox
- Defined in:
- lib/switchbox.rb
Instance Attribute Summary collapse
-
#left ⇒ Object
Returns the value of attribute left.
-
#right ⇒ Object
Returns the value of attribute right.
Instance Method Summary collapse
-
#initialize ⇒ Switchbox
constructor
A new instance of Switchbox.
- #left_flip ⇒ Object
- #right_flip ⇒ Object
Constructor Details
#initialize ⇒ Switchbox
Returns a new instance of Switchbox.
3 4 5 6 7 8 9 10 11 12 13 14 15 |
# File 'lib/switchbox.rb', line 3 def initialize if rand(2) == 0 @left = :ON else @left = :OFF end if rand(2) == 0 @right = :ON else @right = :OFF end end |
Instance Attribute Details
#left ⇒ Object
Returns the value of attribute left.
2 3 4 |
# File 'lib/switchbox.rb', line 2 def left @left end |
#right ⇒ Object
Returns the value of attribute right.
2 3 4 |
# File 'lib/switchbox.rb', line 2 def right @right end |
Instance Method Details
#left_flip ⇒ Object
17 18 19 20 21 22 23 |
# File 'lib/switchbox.rb', line 17 def left_flip if @left == :ON @left = :OFF else @left = :ON end end |
#right_flip ⇒ Object
25 26 27 28 29 30 31 |
# File 'lib/switchbox.rb', line 25 def right_flip if @right == :ON @right = :OFF else @right = :ON end end |