Sha256: 3a98f862399417d9bbd32cbdd4959ef872f22874a8e81d3b7419d1dea21d98e3

Contents?: true

Size: 491 Bytes

Versions: 1

Compression:

Stored size: 491 Bytes

Contents

require 'nokogiri'

module Nokogiri
  module XML
    class Document < Node

      #
      # Calculates the sum of all sub-children of the document.
      #
      # @return [Integer]
      #   The total number of children and sub-children of the document.
      #   Returns `0` if the document has no root element.
      #
      # @api public
      #
      def traverse_count
        if root
          1 + root.traverse_count
        else
          0
        end
      end

    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
nokogiri-ext-0.1.0 lib/nokogiri/ext/traverse_count/document.rb