class Object

Public Instance Methods

e_read(n, mesg = nil) click to toggle source

Reads exactly n bytes.

If the data read is nil an EOFError is raised.

If the data read is too short a MissingDataError is raised and the read data is obtainable via its data method.

# File lib/nwn/io.rb, line 24
def e_read(n, mesg = nil)
  str = read(n)
  if str == nil
    raise EOFError, "End of file reached"
  end
  if str.size < n
    raise MissingDataError.new("data truncated" + (mesg ? ": " + mesg : nil), str)
  end
  str
end