Module: FastBitset
- Defined in:
- lib/fast_bitset.rb,
lib/fast_bitset/version.rb,
ext/fast_bitset/fast_bitset.c
Constant Summary collapse
- VERSION =
"0.0.1"
Class Method Summary collapse
Class Method Details
.pure_bitstring_to_ids(value) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/fast_bitset.rb', line 5 def self.pure_bitstring_to_ids(value) unless value.is_a?(String) raise TypeError.new("wrong argument type #{value.class} (expected String)") end offset = 0 ids = [] return ids if value.nil? value.each_byte do |byte| 7.downto(0) do |i| value = (1<<i) ids << offset if (value & byte) == value offset += 1 end end ids end |