Class: Hyperll::Varint

Inherits:
Object
  • Object
show all
Defined in:
lib/hyperll/varint.rb

Class Method Summary collapse

Class Method Details

.read_unsigned_var_int(bytes) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
# File 'lib/hyperll/varint.rb', line 3

def self.read_unsigned_var_int(bytes)
  value, i, b = 0, 0, 0
  while (b = bytes.shift) & 0x80 != 0
    value |= (b & 0x7F) << i

    i += 7
    raise "Variable length quantity is too long" if i > 35
  end

  value | (b << i)
end