Sha256: dbb44e4cad66ade84f7332ecea07fb845d2b06186a6d57468dbf76a45dd7add5

Contents?: true

Size: 1.65 KB

Versions: 8

Compression:

Stored size: 1.65 KB

Contents

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, Fixnum, 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

Version data entries

8 entries across 8 versions & 3 rubygems

Version Path
rmagick-windows-2.16.5 lib/rvg/deep_equal.rb
rmagick-windows-2.16.4 lib/rvg/deep_equal.rb
rmagick-windows-2.16.3 lib/rvg/deep_equal.rb
rmagick-windows-2.16.2 lib/rvg/deep_equal.rb
rmagick-windows-2.16.1 lib/rvg/deep_equal.rb
mdg-1.0.1 vendor/bundle/ruby/2.3.0/gems/rmagick-2.16.0/lib/rvg/deep_equal.rb
rmagick-2.16.0 lib/rvg/deep_equal.rb
rmagick-2.15.4 lib/rvg/deep_equal.rb