Sha256: 8a1f8cf936b632246f09f3f96e9e194663c5cd0830eb9fa07b66a6c5954ae996

Contents?: true

Size: 1.02 KB

Versions: 36

Compression:

Stored size: 1.02 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 @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

36 entries across 36 versions & 1 rubygems

Version Path
ox-1.5.5 lib/ox/document.rb
ox-1.5.4 lib/ox/document.rb
ox-1.5.3 lib/ox/document.rb
ox-1.5.2 lib/ox/document.rb
ox-1.5.1 lib/ox/document.rb
ox-1.5.0 lib/ox/document.rb
ox-1.4.6 lib/ox/document.rb
ox-1.4.5 lib/ox/document.rb
ox-1.4.4 lib/ox/document.rb
ox-1.4.3 lib/ox/document.rb
ox-1.4.2 lib/ox/document.rb
ox-1.4.1 lib/ox/document.rb
ox-1.4.0 lib/ox/document.rb
ox-1.3.5 lib/ox/document.rb
ox-1.3.4 lib/ox/document.rb
ox-1.3.3 lib/ox/document.rb