Class: Nokogiri::XML::Node
- Inherits:
-
Object
- Object
- Nokogiri::XML::Node
- Defined in:
- lib/nokogiri/ext/equality/node.rb,
lib/nokogiri/ext/traverse_text.rb,
lib/nokogiri/ext/traverse_count/node.rb
Instance Method Summary collapse
-
#==(other) ⇒ Boolean
Determines if the node is similar to another node.
-
#traverse_count ⇒ Integer
Calculates the sum of all children of the node.
-
#traverse_text {|node| ... } ⇒ Enumerator
Traverses all text nodes which are children of the node.
Instance Method Details
#==(other) ⇒ Boolean
Determines if the node is similar to another node.
18 19 20 21 22 |
# File 'lib/nokogiri/ext/equality/node.rb', line 18 def ==(other) return false unless other (self.type == other.type) && (self.name == other.name) end |
#traverse_count ⇒ Integer
Calculates the sum of all children of the node.
17 18 19 20 21 22 23 |
# File 'lib/nokogiri/ext/traverse_count/node.rb', line 17 def traverse_count count = 0 traverse { |node| count += 1 } return count - 1 end |
#traverse_text {|node| ... } ⇒ Enumerator
Traverses all text nodes which are children of the node.
23 24 25 26 27 28 29 30 31 |
# File 'lib/nokogiri/ext/traverse_text.rb', line 23 def traverse_text return enum_for(:traverse_text) unless block_given? yield self if text? traverse do |node| yield node if node.text? end end |