Method: Cosmos::Structure#write_item
- Defined in:
- lib/cosmos/packets/structure.rb
#write_item(item, value, value_type = :RAW, buffer = @buffer) ⇒ Object
Write a value to the buffer based on the item definition
349 350 351 352 353 354 355 356 |
# File 'lib/cosmos/packets/structure.rb', line 349 def write_item(item, value, value_type = :RAW, buffer = @buffer) buffer = allocate_buffer_if_needed() unless buffer if item.array_size BinaryAccessor.write_array(value, item.bit_offset, item.bit_size, item.data_type, item.array_size, buffer, item.endianness, item.overflow) else BinaryAccessor.write(value, item.bit_offset, item.bit_size, item.data_type, buffer, item.endianness, item.overflow) end end |