Class: HarlemBits::Bit
- Inherits:
-
Object
- Object
- HarlemBits::Bit
- Defined in:
- lib/harlem_bits/bit.rb
Instance Method Summary collapse
-
#initialize(color, on = false) ⇒ Bit
constructor
A new instance of Bit.
- #off ⇒ Object
- #switch ⇒ Object
- #to_s ⇒ Object (also: #inspect)
Constructor Details
#initialize(color, on = false) ⇒ Bit
Returns a new instance of Bit.
3 4 5 |
# File 'lib/harlem_bits/bit.rb', line 3 def initialize(color, on = false) @color, @on = color, on end |
Instance Method Details
#off ⇒ Object
11 12 13 |
# File 'lib/harlem_bits/bit.rb', line 11 def off @on = false end |
#switch ⇒ Object
7 8 9 |
# File 'lib/harlem_bits/bit.rb', line 7 def switch @on = !@on end |
#to_s ⇒ Object Also known as: inspect
15 16 17 |
# File 'lib/harlem_bits/bit.rb', line 15 def to_s @on ? ('1'.send(@color) rescue '1') : '0' end |