Class: BitArray

Inherits:
Object
  • Object
show all
Defined in:
lib/rpl/interpreter.rb

Instance Method Summary collapse

Constructor Details

#initializeBitArray

Returns a new instance of BitArray.



11
12
13
# File 'lib/rpl/interpreter.rb', line 11

def initialize
  @mask = 0
end

Instance Method Details

#[](position) ⇒ Object



23
24
25
# File 'lib/rpl/interpreter.rb', line 23

def [](position)
  @mask[position]
end

#[]=(position, value) ⇒ Object



15
16
17
18
19
20
21
# File 'lib/rpl/interpreter.rb', line 15

def []=(position, value)
  if value.zero?
    @mask ^= (1 << position)
  else
    @mask |= (1 << position)
  end
end