Sha256: 0be6cb3bf892f1fd95a2219e4434706432def8dcbe7c36b1e975424b1dcdc7f4

Contents?: true

Size: 1.05 KB

Versions: 38

Compression:

Stored size: 1.05 KB

Contents

module Ox
  # Represents an XML document. It has a fixed set of attributes which form
  # the XML prolog. A Document includes Elements.
  class Document < Element
    # Create a new Document.
    # @param [Hash] prolog prolog attributes
    # @option prolog [String] :version version, typically '1.0' or '1.1'
    # @option prolog [String] :encoding encoding for the document, currently included but ignored
    # @option prolog [String] :standalone indicates the document is standalone
    def initialize(prolog={})
      super(nil)
      @attributes = { }
      @attributes[:version] = prolog[:version] unless prolog[:version].nil?
      @attributes[:encoding] = prolog[:encoding] unless prolog[:encoding].nil?
      @attributes[:standalone] = prolog[:standalone] unless prolog[:standalone].nil?
    end
    
    # Returns the first Element in the document.
    def root()
      unless !instance_variable_defined?(:@nodes) || @nodes.nil?
        @nodes.each do |n|
          return n if n.is_a?(::Ox::Element)
        end
      end
      nil
    end

  end # Document
end # Ox

Version data entries

38 entries across 38 versions & 1 rubygems

Version Path
ox-2.3.0 lib/ox/document.rb
ox-2.2.4 lib/ox/document.rb
ox-2.2.3 lib/ox/document.rb
ox-2.2.2 lib/ox/document.rb
ox-2.2.1 lib/ox/document.rb
ox-2.2.0 lib/ox/document.rb
ox-2.1.8 lib/ox/document.rb
ox-2.1.7 lib/ox/document.rb
ox-2.1.6 lib/ox/document.rb
ox-2.1.5 lib/ox/document.rb
ox-2.1.4 lib/ox/document.rb
ox-2.1.3 lib/ox/document.rb
ox-2.1.2 lib/ox/document.rb
ox-2.1.1 lib/ox/document.rb
ox-2.1.0 lib/ox/document.rb
ox-2.0.12 lib/ox/document.rb
ox-2.0.11 lib/ox/document.rb
ox-2.0.9 lib/ox/document.rb
ox-2.0.8 lib/ox/document.rb
ox-2.0.7 lib/ox/document.rb