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.



508
509
510
511
512
513
514
515
516
517
# File 'lib/openc3/packets/structure.rb', line 508

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