Class: Array

Inherits:
Object
  • Object
show all
Defined in:
lib/has_many_booleans/simple_bitset.rb

Overview

binary representation/bitset: store an array of indices in one decimal number

Instance Method Summary collapse

Instance Method Details

#to_briObject

Generates an integer representing all the set bits



7
8
9
# File 'lib/has_many_booleans/simple_bitset.rb', line 7

def to_bri # to binary representation integer
  self.inject(0){ |ret, cur| ret + 2**cur }
end