1 2 3 4 5 6 7 8 9 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 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52
|
module Magick
class RVG
[PathData, Styles, Transforms].each do |c|
c.class_eval do
def deep_equal(other)
if self != other
puts "#{c.inspect} not equal.\nself:#{self} != other:#{other}"
return false
end
true
end
end
end
[Shape, TextBase, Image, Group, Content, Use, ClipPath, Pattern, self].each do |c|
c.class_eval do
def deep_equal(other)
ivs = instance_variables
ivs.each do |iv|
itv = instance_variable_get(iv)
otv = other.instance_variable_get(iv)
if itv.respond_to?(:deep_equal)
if itv.equal?(otv)
puts "#{iv} has deep_equal but self.#{iv} and other.#{iv} are the same object."
return false
end
unless itv.deep_equal(otv)
puts "Not equal.\nself.#{iv}=#{itv.inspect}\nother.#{iv}=#{otv.inspect}"
return false
end
else
case itv
when Float, Symbol, TrueClass, FalseClass, Integer, NilClass
return false if itv != otv
else
if itv.equal?(otv)
puts "#{iv} is dup-able but self.#{iv} and other.#{iv} are the same object."
return false
end
if itv != otv
puts "Not equal.\nself.#{iv}=#{itv.inspect}\nother.#{iv}=#{otv.inspect}"
return false
end
end
end
end
true
end
end
end
end # class RVG
end # module Magick
|