Class: LEON::BufferIterator
Instance Method Summary collapse
-
#initialize(buf) ⇒ BufferIterator
constructor
A new instance of BufferIterator.
- #readDouble ⇒ Object
- #readFloat ⇒ Object
- #readInt16 ⇒ Object
- #readInt32 ⇒ Object
- #readInt8 ⇒ Object
- #readUInt16 ⇒ Object
- #readUInt32 ⇒ Object
- #readUInt8 ⇒ Object
- #readValue(type) ⇒ Object
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
#readDouble ⇒ Object
37 38 39 40 |
# File 'lib/buffer-iterator.rb', line 37 def readDouble() @i += 8 return @buffer.readDoubleLE(@i - 8) end |
#readFloat ⇒ Object
33 34 35 36 |
# File 'lib/buffer-iterator.rb', line 33 def readFloat() @i += 4 return @buffer.readFloatLE(@i - 4) end |
#readInt16 ⇒ Object
21 22 23 24 |
# File 'lib/buffer-iterator.rb', line 21 def readInt16() @i += 2 return @buffer.readInt16LE(@i - 2) end |
#readInt32 ⇒ Object
29 30 31 32 |
# File 'lib/buffer-iterator.rb', line 29 def readInt32() @i += 4 return @buffer.readInt32LE(@i - 4) end |
#readInt8 ⇒ Object
13 14 15 16 |
# File 'lib/buffer-iterator.rb', line 13 def readInt8() @i += 1 return @buffer.readInt8(@i - 1) end |
#readUInt16 ⇒ Object
17 18 19 20 |
# File 'lib/buffer-iterator.rb', line 17 def readUInt16() @i += 2 return @buffer.readUInt16LE(@i - 2) end |
#readUInt32 ⇒ Object
25 26 27 28 |
# File 'lib/buffer-iterator.rb', line 25 def readUInt32() @i += 4 return @buffer.readUInt32LE(@i - 4) end |
#readUInt8 ⇒ Object
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 |