Sha256: 6f6d3a857af3e448d074694288aefb17252d4273d41dfd2cd0a90dbc4c3ab6df

Contents?: true

Size: 1.03 KB

Versions: 54

Compression:

Stored size: 1.03 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.
    # - +prolog+ [Hash] prolog attributes
    #   - _:version_ [String] version, typically '1.0' or '1.1'
    #   - _:encoding_ [String] encoding for the document, currently included but ignored
    #   - _:standalone_ [String] 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

54 entries across 54 versions & 2 rubygems

Version Path
ox-2.14.14 lib/ox/document.rb
ox-2.14.13 lib/ox/document.rb
ox-2.14.12 lib/ox/document.rb
ox-2.14.11 lib/ox/document.rb
ox-2.14.10 lib/ox/document.rb
ox-2.14.9 lib/ox/document.rb
ox-2.14.8 lib/ox/document.rb
ox-2.14.7 lib/ox/document.rb
ox-2.14.6 lib/ox/document.rb
ox-2.14.5 lib/ox/document.rb
ox-2.14.4 lib/ox/document.rb
ox-2.14.3 lib/ox/document.rb
ox-2.14.2 lib/ox/document.rb
ox-2.14.1 lib/ox/document.rb
ox-2.14.0 lib/ox/document.rb
ox-2.13.4 lib/ox/document.rb
ox-2.13.3 lib/ox/document.rb
ox-2.13.2 lib/ox/document.rb
ox-2.13.1 lib/ox/document.rb
ox-2.12.1 lib/ox/document.rb