Sha256: 6f5be4546a4d906a768d91bada76d58e1a1ec9142dcb3133a88209ae8fc51908

Contents?: true

Size: 522 Bytes

Versions: 1

Compression:

Stored size: 522 Bytes

Contents

# frozen_string_literal: true

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.1 lib/nokogiri/ext/traverse_count/document.rb