module Pliney::IOHelpers
Public Instance Methods
read_uint16be()
click to toggle source
# File lib/pliney/io_helpers.rb, line 24 def read_uint16be strictread(2).unpack("n").first end
Also aliased as: read_uint16
read_uint16le()
click to toggle source
# File lib/pliney/io_helpers.rb, line 41 def read_uint16le strictread(2).unpack("v").first end
read_uint32be()
click to toggle source
# File lib/pliney/io_helpers.rb, line 28 def read_uint32be strictread(4).unpack("N").first end
Also aliased as: read_uint32
read_uint32le()
click to toggle source
# File lib/pliney/io_helpers.rb, line 45 def read_uint32le strictread(4).unpack("V").first end
read_uint64be()
click to toggle source
# File lib/pliney/io_helpers.rb, line 32 def read_uint64be v = strictread(8).unpack("NN") (v[0] << 32) | v[1] end
Also aliased as: read_uint64
read_uint64le()
click to toggle source
# File lib/pliney/io_helpers.rb, line 49 def read_uint64le v = strictread(8).unpack("VV") (v[1] << 32) | v[0] end
read_uint8()
click to toggle source
# File lib/pliney/io_helpers.rb, line 20 def read_uint8 getbyte end
strictread(nbytes)
click to toggle source
# File lib/pliney/io_helpers.rb, line 8 def strictread(nbytes) _pos = self.pos res = read(nbytes) if res.nil? raise(StrictReadError, "read returned nil for read(#{nbytes}) at offset #{_pos}") end if res.bytesize != nbytes raise(StrictReadError, "read returned only #{res.size} bytes for read(#{nbytes}) at offset #{_pos}") end return res end