Module Magick::RVG::Duplicatable
In: lib/rvg/misc.rb
Enum GeometryValue Stylable RVG\n[lib/rvg/clippath.rb\nlib/rvg/container.rb\nlib/rvg/deep_equal.rb\nlib/rvg/describable.rb\nlib/rvg/embellishable.rb\nlib/rvg/misc.rb\nlib/rvg/paint.rb\nlib/rvg/pathdata.rb\nlib/rvg/rvg.rb\nlib/rvg/stretchable.rb\nlib/rvg/stylable.rb\nlib/rvg/text.rb\nlib/rvg/transformable.rb\nlib/rvg/units.rb] Transformable Stretchable Embellishable Describable Duplicatable Comparable Image ImageList Array Geometry HatchFill Draw lib/RMagick.rb lib/rvg/units.rb Magick Module: Magick

This is a standard deep_copy method that is used in most classes. Thanks to Robert Klemme.

Methods

deep_copy  

Public Instance methods

[Source]

    # File lib/rvg/misc.rb, line 9
 9:         def deep_copy(h = {})
10:             # Prevent recursion. If we reach the
11:             # object we started with, stop copying.
12:             copy = h[__id__]
13:             unless copy
14:                 h[__id__] = copy = self.class.allocate
15:                 ivars = instance_variables
16:                 ivars.each do |ivar|
17:                     ivalue = instance_variable_get(ivar)
18:                     cvalue = case
19:                         when NilClass === ivalue, Symbol === ivalue, Float === ivalue,
20:                              Fixnum === ivalue, FalseClass === ivalue, TrueClass === ivalue
21:                             ivalue
22:                         when ivalue.respond_to?(:deep_copy)
23:                             ivalue.deep_copy(h)
24:                         when ivalue.respond_to?(:dup)
25:                             ivalue.dup
26:                         else
27:                             ivalue
28:                         end
29:                     copy.instance_variable_set(ivar, cvalue)
30:                 end
31:                 copy.freeze if frozen?
32:             end
33:             return copy
34:         end

[Validate]