Added XML::NodeSet#==

This method can be used to compare two NodeSet instances. By using
XML::NodeSet#equal_nodes?() the need for exposing the "nodes" instance variable
is also removed.
This commit is contained in:
Yorick Peterse committed 2014-11-09 18:33:16 +01:00
1 parent 7e38e20586
commit 857ac517d5
2 files changed
+39

No files matched your search

+22
View File
@@ -197,6 +197,28 @@ module Oga
return self.class.new(to_a | other.to_a)
end
##
# Returns `true` if the current node set and the one given in `other` are
# equal to each other.
#
# @param [Oga::XML::NodeSet] other
#
def ==(other)
return other.is_a?(NodeSet) && other.equal_nodes?(@nodes)
end
##
# Returns `true` if the nodes given in `nodes` are equal to those
# specified in the current `@nodes` variable. This method allows two
# NodeSet instances to compare each other without the need of exposing
# `@nodes` to the public.
#
# @param [Array<Oga::XML::Node>] nodes
#
def equal_nodes?(nodes)
return @nodes == nodes
end
##
# Adds the nodes of the given node set to the current node set.
#