Class: HarlemBits::Bit

Inherits:
Object
  • Object
show all
Defined in:
lib/harlem_bits/bit.rb

Instance Method Summary collapse

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

#offObject



11
12
13
# File 'lib/harlem_bits/bit.rb', line 11

def off
  @on = false
end

#switchObject



7
8
9
# File 'lib/harlem_bits/bit.rb', line 7

def switch
  @on = !@on 
end

#to_sObject 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