Sha256: c22875ed2ed260b5cf224a1cb70bc7a914c8d0a549673b0402e60109b0c5f0cf

Contents?: true

Size: 768 Bytes

Versions: 1

Compression:

Stored size: 768 Bytes

Contents

require 'nokogiri/xml/node'

module Nokogiri
  module XML
    class Node

      #
      # Returns the total count of all sub-children of the node.
      #
      def total_children
        count = 0
        first = self.child

        return count unless first

        while first
          count += (1 + first.total_children)

          first = first.next
        end

        count
      end

      def traverse_text(&block)
        block.call(self) if text?

        first = self.child

        while first
          first.traverse_text(&block)

          first = first.next
        end

        self
      end

      def similar?(other)
        return false unless other

        (self.type == other.type) && (self.name == other.name)
      end

    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ronin-web-0.1.0 lib/ronin/web/extensions/nokogiri/xml/node.rb