Class: Capnp::IOBuffer
- Inherits:
-
Object
- Object
- Capnp::IOBuffer
- Extended by:
- T::Sig
- Includes:
- SliceableBuffer
- Defined in:
- lib/capnp/runtime/buffer/io_buffer.rb
Instance Method Summary collapse
-
#initialize(buffer) ⇒ IOBuffer
constructor
A new instance of IOBuffer.
- #read_bytes(offset, length) ⇒ Object
- #read_f32(offset) ⇒ Object
- #read_f64(offset) ⇒ Object
- #read_s16(offset) ⇒ Object
- #read_s32(offset) ⇒ Object
- #read_s64(offset) ⇒ Object
- #read_s8(offset) ⇒ Object
- #read_string(offset, length) ⇒ Object
- #read_u16(offset) ⇒ Object
- #read_u32(offset) ⇒ Object
- #read_u64(offset) ⇒ Object
- #read_u8(offset) ⇒ Object
- #size ⇒ Object
- #slice(offset, length) ⇒ Object
Constructor Details
#initialize(buffer) ⇒ IOBuffer
Returns a new instance of IOBuffer.
12 13 14 |
# File 'lib/capnp/runtime/buffer/io_buffer.rb', line 12 def initialize(buffer) @buffer = buffer end |
Instance Method Details
#read_bytes(offset, length) ⇒ Object
27 28 29 |
# File 'lib/capnp/runtime/buffer/io_buffer.rb', line 27 def read_bytes(offset, length) @buffer.get_string(offset, length, Encoding::BINARY) end |
#read_f32(offset) ⇒ Object
72 73 74 |
# File 'lib/capnp/runtime/buffer/io_buffer.rb', line 72 def read_f32(offset) T.cast(@buffer.get_value(:f32, offset), Float) end |
#read_f64(offset) ⇒ Object
77 78 79 |
# File 'lib/capnp/runtime/buffer/io_buffer.rb', line 77 def read_f64(offset) T.cast(@buffer.get_value(:f64, offset), Float) end |
#read_s16(offset) ⇒ Object
57 58 59 |
# File 'lib/capnp/runtime/buffer/io_buffer.rb', line 57 def read_s16(offset) T.cast(@buffer.get_value(:s16, offset), Integer) end |
#read_s32(offset) ⇒ Object
62 63 64 |
# File 'lib/capnp/runtime/buffer/io_buffer.rb', line 62 def read_s32(offset) T.cast(@buffer.get_value(:s32, offset), Integer) end |
#read_s64(offset) ⇒ Object
67 68 69 |
# File 'lib/capnp/runtime/buffer/io_buffer.rb', line 67 def read_s64(offset) T.cast(@buffer.get_value(:s64, offset), Integer) end |
#read_s8(offset) ⇒ Object
52 53 54 |
# File 'lib/capnp/runtime/buffer/io_buffer.rb', line 52 def read_s8(offset) T.cast(@buffer.get_value(:S8, offset), Integer) end |
#read_string(offset, length) ⇒ Object
22 23 24 |
# File 'lib/capnp/runtime/buffer/io_buffer.rb', line 22 def read_string(offset, length) @buffer.get_string(offset, length, Encoding::UTF_8) end |
#read_u16(offset) ⇒ Object
37 38 39 |
# File 'lib/capnp/runtime/buffer/io_buffer.rb', line 37 def read_u16(offset) T.cast(@buffer.get_value(:u16, offset), Integer) end |
#read_u32(offset) ⇒ Object
42 43 44 |
# File 'lib/capnp/runtime/buffer/io_buffer.rb', line 42 def read_u32(offset) T.cast(@buffer.get_value(:u32, offset), Integer) end |
#read_u64(offset) ⇒ Object
47 48 49 |
# File 'lib/capnp/runtime/buffer/io_buffer.rb', line 47 def read_u64(offset) T.cast(@buffer.get_value(:u64, offset), Integer) end |
#read_u8(offset) ⇒ Object
32 33 34 |
# File 'lib/capnp/runtime/buffer/io_buffer.rb', line 32 def read_u8(offset) T.cast(@buffer.get_value(:U8, offset), Integer) end |
#size ⇒ Object
82 83 84 |
# File 'lib/capnp/runtime/buffer/io_buffer.rb', line 82 def size @buffer.size end |
#slice(offset, length) ⇒ Object
17 18 19 |
# File 'lib/capnp/runtime/buffer/io_buffer.rb', line 17 def slice(offset, length) self.class.new(@buffer.slice(offset, length)) end |