Class: LEON::BufferIterator

Inherits:
Object show all
Defined in:
lib/buffer-iterator.rb

Instance Method Summary collapse

Constructor Details

#initialize(buf) ⇒ BufferIterator

Returns a new instance of BufferIterator.



5
6
7
8
# File 'lib/buffer-iterator.rb', line 5

def initialize(buf)
  @buffer = buf
  @i = 0
end

Instance Method Details

#readDoubleObject



37
38
39
40
# File 'lib/buffer-iterator.rb', line 37

def readDouble()
  @i += 8
  return @buffer.readDoubleLE(@i - 8)
end

#readFloatObject



33
34
35
36
# File 'lib/buffer-iterator.rb', line 33

def readFloat()
  @i += 4
  return @buffer.readFloatLE(@i - 4)
end

#readInt16Object



21
22
23
24
# File 'lib/buffer-iterator.rb', line 21

def readInt16()
  @i += 2
  return @buffer.readInt16LE(@i - 2)
end

#readInt32Object



29
30
31
32
# File 'lib/buffer-iterator.rb', line 29

def readInt32()
  @i += 4
  return @buffer.readInt32LE(@i - 4)
end

#readInt8Object



13
14
15
16
# File 'lib/buffer-iterator.rb', line 13

def readInt8()
  @i += 1
  return @buffer.readInt8(@i - 1)
end

#readUInt16Object



17
18
19
20
# File 'lib/buffer-iterator.rb', line 17

def readUInt16()
  @i += 2
  return @buffer.readUInt16LE(@i - 2)
end

#readUInt32Object



25
26
27
28
# File 'lib/buffer-iterator.rb', line 25

def readUInt32()
  @i += 4
  return @buffer.readUInt32LE(@i - 4)
end

#readUInt8Object



9
10
11
12
# File 'lib/buffer-iterator.rb', line 9

def readUInt8()
  @i += 1
  return @buffer.readUInt8(@i - 1)
end

#readValue(type) ⇒ Object



41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'lib/buffer-iterator.rb', line 41

def readValue(type)
  if type === Constants::UNSIGNED_CHAR
    return readUInt8()
  end
  if type === Constants::CHAR
    return readInt8()
  end
  if type === Constants::UNSIGNED_SHORT
    return readUInt16()
  end
  if type === Constants::SHORT
    return readInt16()
  end
  if type === Constants::UNSIGNED_INT
    return readUInt32()
  end
  if type === Constants::INT
    return readInt32()
  end
  if type === Constants::FLOAT
    return readFloat()
  end
  if type === Constants::DOUBLE
    return readDouble()
  end
end