Method: OpenC3::Structure#append

Defined in:
lib/openc3/packets/structure.rb

#append(item) ⇒ StrutureItem

Adds an item at the end of the structure. It adds the item to the items hash and resizes the buffer to accomodate the new item.

Parameters:

Returns:

  • (StrutureItem)

    The struture item defined

Raises:

  • (ArgumentError)


315
316
317
318
319
320
321
322
323
324
# File 'lib/openc3/packets/structure.rb', line 315

def append(item)
  raise ArgumentError, "Can't append an item after a variably sized item" if !@fixed_size

  if item.data_type == :DERIVED
    item.bit_offset = 0
  else
    item.bit_offset = @defined_length_bits
  end
  return define(item)
end