Method: Steem::Marshal#varint
- Defined in:
- lib/steem/marshal.rb
#varint ⇒ Object
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/steem/marshal.rb', line 61 def varint shift = 0 result = 0 bytes = [] while (n = unsigned_char) >> 7 == 1 bytes << n end bytes << n bytes.each do |b| result += ((b & 0x7f) << shift) break unless (b & 0x80) shift += 7 end result end |