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:



10
11
12
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 10

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