Sha256: 01312cc027ac3eff70c9d96aa155ec2a44a3765b12b4a9eaa02b1ddb23756844

Contents?: true

Size: 804 Bytes

Versions: 1

Compression:

Stored size: 804 Bytes

Contents

require 'nokogiri'

module Nokogiri
  module XML
    class Element < Node

      #
      # Determines if the element is similar to another element.
      #
      # @param [Nokogiri::XML::Element] other
      #   The other element.
      #
      # @return [Boolean]
      #   Specifies whether the element is equal, in identity or value, to
      #   another element.
      #
      # @api public
      #
      def ==(other)
        return false unless super(other)
        return false unless attribute_nodes.length == other.attribute_nodes.length

        (0...attribute_nodes.length).each do |index|
          attr1 = attribute_nodes[index]
          attr2 = other.attribute_nodes[index]

          return false unless attr1.similar?(attr2)
        end

        return true
      end

    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
nokogiri-ext-0.1.0 lib/nokogiri/ext/equality/element.rb