module ChunkyPNG::Chunk
def self.read_bytes(io, length)
-
(ChunkyPNG::ExpectationFailed)- If not exactly length
Returns:
-
(String)- A binary string of exactly length bytes.
Parameters:
-
length(Integer) -- The IO exact number of bytes to read. -
io(IO, #read) -- The IO stream to read from.
def self.read_bytes(io, length) data = io.read(length) raise ExpectationFailed, "Couldn't read #{length} bytes from IO stream." if data.nil? || data.bytesize != length data end