Method: OpenC3::Structure#clone

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

#cloneStructure Also known as: dup

Make a light weight clone of this structure. This only creates a new buffer of data. The defined structure items are the same.

Returns:

  • (Structure)

    A copy of the current structure with a new underlying buffer of data



492
493
494
495
496
497
498
499
500
# File 'lib/openc3/packets/structure.rb', line 492

def clone
  structure = super()
  # Use instance_variable_set since we have overriden buffer= to do
  # additional work that isn't neccessary here
  structure.instance_variable_set("@buffer".freeze, @buffer.clone) if @buffer
  # Need to update reference packet in the Accessor
  structure.accessor.packet = structure
  return structure
end