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 Enumerable Geometry HatchFill Draw lib/RMagick.rb lib/rvg/rvg.rb ObjectData Application Pre_ObjectData_Descriptor Envelope Post_ObjectData_Descriptor IPTC Magick dot/m_14_0.png

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

[Validate]