class Overlook::BitReader

Public Class Methods

new(_buffer) click to toggle source
# File lib/overlook/bit_reader.rb, line 3
def initialize(_buffer)
  @buffer = BitBuffer.new(_buffer)
end

Public Instance Methods

bit() click to toggle source
# File lib/overlook/bit_reader.rb, line 11
def bit
  bits(1)
end
byte() click to toggle source
# File lib/overlook/bit_reader.rb, line 15
def byte
  bits(8)
end
bytes(n) click to toggle source
# File lib/overlook/bit_reader.rb, line 7
def bytes(n)
  @buffer.bytes(n)
end
eof?() click to toggle source
# File lib/overlook/bit_reader.rb, line 35
def eof?
  @buffer.eof?
end
int32() click to toggle source
# File lib/overlook/bit_reader.rb, line 28
def int32
  ret  =  byte
  ret |=  byte << 8
  ret |=  byte << 16
  ret |=  byte << 24
end
short() click to toggle source
# File lib/overlook/bit_reader.rb, line 23
def short
  ret  =  byte
  ret |=  byte << 8
end
skip(n) click to toggle source
# File lib/overlook/bit_reader.rb, line 19
def skip(n)
  @buffer.skip(n)
end
var_int(max_len) click to toggle source
# File lib/overlook/bit_reader.rb, line 43
def var_int(max_len)
  _byte = 0
  count = 0
  result = 0

  loop do
    return result if count + 1 == max_len
    _byte = self.byte
    result |= (_byte & 0x7F) << (7 * count)
    count = count + 1
    break if _byte & 0x80 == 0
  end
  result
end
var_int32() click to toggle source
# File lib/overlook/bit_reader.rb, line 39
def var_int32
  var_int(4)
end

Private Instance Methods

bits(numbits) click to toggle source
# File lib/overlook/bit_reader.rb, line 60
def bits(numbits)
  @buffer.bits(numbits)
end