lib/bindata/io.rb
# Reads exactly +nbits+ big endian bits from the stream.
Reads exactly +nbits+ big endian bits from the stream.
Reads exactly + nbits + big endian bits from the stream .
def read_be_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 << 8) | byte
        @rnbits += 8
      end
      val     = (@rval >> (@rnbits - nbits)) & ((1 << nbits) - 1)
      @rnbits -= nbits
      @rval   &= ((1 << @rnbits) - 1)
      val
    end
def read_be_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 << 8 ) | byte @rnbits += 8 end val = ( @rval >> ( @rnbits - nbits ) ) & ( ( 1 << nbits ) - 1 ) @rnbits -= nbits @rval &= ( ( 1 << @rnbits ) - 1 ) val end
Reads exactly +nbits+ big endian bits from the stream.
Reads exactly + nbits + big endian bits from the stream .
# ensure enough bits have accumulated
nbits
<not_specific>