Skip to content

Commit

Permalink
Add read_varint rdoc
Browse files Browse the repository at this point in the history
  • Loading branch information
durran committed Dec 27, 2012
1 parent 48b6a65 commit 0429ae0
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions lib/protocop/buffer.rb
Expand Up @@ -146,6 +146,17 @@ def read_int64
value
end

# Read a variable byte length integer from the buffer. The number of bytes
# that are read will depend on the value of the integer.
#
# @example Read the varint from the buffer.
# buffer.read_varint
#
# @return [ Integer ] The integer.
#
# @see https://developers.google.com/protocol-buffers/docs/encoding
#
# @since 0.0.0
def read_varint
value, shift = 0, 0
while (byte = read(1).ord) do
Expand Down

0 comments on commit 0429ae0

Please sign in to comment.