Class: BitArray

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

Instance Method Summary collapse

Constructor Details

#initializeBitArray

Returns a new instance of BitArray.



8
9
10
# File 'lib/rpl/types/grob.rb', line 8

def initialize
  @mask = 0
end

Instance Method Details

#[](position) ⇒ Object



20
21
22
# File 'lib/rpl/types/grob.rb', line 20

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

#[]=(position, value) ⇒ Object



12
13
14
15
16
17
18
# File 'lib/rpl/types/grob.rb', line 12

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

#from_i(value) ⇒ Object



28
29
30
# File 'lib/rpl/types/grob.rb', line 28

def from_i( value )
  @mask = value.to_i
end

#to_iObject



24
25
26
# File 'lib/rpl/types/grob.rb', line 24

def to_i
  @mask.to_i
end