Class: Ox::Document
Overview
Represents an XML document. It has a fixed set of attributes which form the XML prolog. A Document includes Elements.
Instance Attribute Summary
Attributes inherited from Node
Instance Method Summary collapse
-
#initialize(prolog = {}) ⇒ Document
constructor
Create a new Document.
-
#root ⇒ Object
Returns the first Element in the document.
Methods inherited from Element
#<<, #alocate, #eql?, #locate, #method_missing, #nodes, #respond_to?, #text
Methods included from HasAttrs
#[], #[]=, #attributes, #method_missing
Methods inherited from Node
Constructor Details
#initialize(prolog = {}) ⇒ Document
Create a new Document.
11 12 13 14 15 16 17 |
# File 'lib/ox/document.rb', line 11 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 |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Ox::Element
Instance Method Details
#root ⇒ Object
Returns the first Element in the document.
20 21 22 23 24 25 26 27 |
# File 'lib/ox/document.rb', line 20 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 |