Method: Noyes::BitArray#shift

Defined in:
lib/ruby_impl/compression.rb

#shiftObject

Returns the first bit and removes it, shifting all bits by one.



116
117
118
119
120
121
122
123
124
125
126
127
# File 'lib/ruby_impl/compression.rb', line 116

def shift
  return if @array.empty?
  bit = @array.first & 0x80000000 >> @start_bit == 0 ? 0 : 1
  if @start_bit == 31
    @start_bit = 0
    @end_bit -= 32
    @array.shift
  else
    @start_bit += 1
  end
  bit
end