Class: Magick::RVG::Content

Inherits:
Array
  • Object
show all
Defined in:
lib/rvg/container.rb

Overview

Content is simply an Array with a deep_copy method. When unit-testing, it also has a deep_equal method.

Instance Method Summary collapse

Instance Method Details

#deep_copy(h = {}) ⇒ Object

:nodoc:


13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/rvg/container.rb', line 13

def deep_copy(h = {})
    me = self.__id__
    copy = h[me]
    unless copy
        copy = self.class.new
        each do |c|
            copy << case
                when c.nil?
                    nil
                when c.respond_to?(:deep_copy)
                    c.deep_copy(h)
                when c.respond_to?(:dup)
                    c.dup rescue c
                else
                    c
                end
        end
        copy.freeze if frozen?
        h[me] = copy
    end
    return copy
end