lib/bindata/io.rb
# Reads exactly +nbits+ little endian bits from the stream.
Reads exactly +nbits+ little endian bits from the stream.
Reads exactly + nbits + little endian bits from the stream .
def read_le_bits(nbits)
      while nbits > @rnbits
        byte = @raw_io.read(1)
        raise EOFError, "End of file reached" if byte.nil?
        byte = byte.unpack('C').at(0) & 0xff
        @rval = @rval | (byte << @rnbits)
        @rnbits += 8
      end
      val     = @rval & ((1 << nbits) - 1)
      @rnbits -= nbits
      @rval   >>= nbits
      val
    end
def read_le_bits ( nbits ) while nbits > @rnbits byte = @raw_io . read ( 1 ) raise EOFError , "End of file reached" if byte . nil? byte = byte . unpack ( 'C' ) . at ( 0 ) & 0xff @rval = @rval | ( byte << @rnbits ) @rnbits += 8 end val = @rval & ( ( 1 << nbits ) - 1 ) @rnbits -= nbits @rval >>= nbits val end
Reads exactly +nbits+ little endian bits from the stream.
Reads exactly + nbits + little endian bits from the stream .
# ensure enough bits have accumulated
nbits
<not_specific>