module MrbParser::Utils
Public Instance Methods
pos()
click to toggle source
# File lib/mrb_parser/utils.rb, line 7 def pos @data.pos end
read(n)
click to toggle source
# File lib/mrb_parser/utils.rb, line 3 def read(n) @data.read(n) end
read_chars(n)
click to toggle source
# File lib/mrb_parser/utils.rb, line 36 def read_chars(n) read_format("a#{n}", n) end
read_format(pat, n)
click to toggle source
# File lib/mrb_parser/utils.rb, line 15 def read_format(pat, n) byteseq = @data.read(n) val = byteseq.unpack(pat)[0] if @verbose p [@data, n, val] end val end
read_n16string()
click to toggle source
# File lib/mrb_parser/utils.rb, line 40 def read_n16string len = read_uint16 read_format("a#{len}", len) end
read_uint16()
click to toggle source
# File lib/mrb_parser/utils.rb, line 28 def read_uint16 read_format("n1", 2) end
read_uint32()
click to toggle source
# File lib/mrb_parser/utils.rb, line 32 def read_uint32 read_format("N1", 4) end
read_uint8()
click to toggle source
# File lib/mrb_parser/utils.rb, line 24 def read_uint8 read_format("C1", 1) end
seek(n)
click to toggle source
# File lib/mrb_parser/utils.rb, line 11 def seek(n) @data.seek(n) end