class LimitedIO

Public Instance Methods

eof?() click to toggle source
# File lib/protocol_buffers/limited_io.rb, line 16
def eof?
  limit == 0 || parent.eof?
end
getbyte() click to toggle source
# File lib/protocol_buffers/limited_io.rb, line 20
def getbyte
  return nil if limit == 0
  self.limit -= 1
  parent.getbyte
end
read(length = nil, buffer = nil) click to toggle source
# File lib/protocol_buffers/limited_io.rb, line 2
def read(length = nil, buffer = nil)
  length = length || limit
  length = limit if length > limit
  self.limit -= length
  # seems silly to check for buffer, but some IO#read methods implemented in C
  # barf if you pass nil, rather than treat it as an argument that wasn't
  # passed at all.
  if buffer
    parent.read(length, buffer)
  else
    parent.read(length)
  end
end