Class: BitArray
- Inherits:
-
Object
- Object
- BitArray
- Defined in:
- lib/rpl/types/grob.rb
Instance Method Summary collapse
- #[](position) ⇒ Object
- #[]=(position, value) ⇒ Object
- #from_i(value) ⇒ Object
-
#initialize ⇒ BitArray
constructor
A new instance of BitArray.
- #to_i ⇒ Object
Constructor Details
#initialize ⇒ BitArray
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_i ⇒ Object
24 25 26 |
# File 'lib/rpl/types/grob.rb', line 24 def to_i @mask.to_i end |