Class: Duxml::Doc
- Includes:
- ElementGuts
- Defined in:
- lib/duxml/doc.rb
Constant Summary
Constants included from Duxml
Constants included from Meta
Instance Attribute Summary
Attributes included from Duxml
Attributes included from Saxer
Instance Method Summary collapse
-
#initialize(prolog = {}) ⇒ Doc
constructor
A new instance of Doc.
- #to_s ⇒ Object
- #write_to(path) ⇒ Object
Methods included from ElementGuts
#<<, #[]=, #abstract?, #delete, #description, #each, #history, #inspect, #name_space, #stub, #traverse
Methods included from LazyOx
Methods included from Reportable
Methods included from Duxml
#create, #load, #log, #relaxng, #save, #validate
Methods included from Meta
Methods included from Saxer
Constructor Details
#initialize(prolog = {}) ⇒ Doc
Returns a new instance of Doc.
8 9 10 11 12 13 |
# File 'lib/duxml/doc.rb', line 8 def initialize(prolog={}) super(prolog) self[:version] ||= '1.0' @nodes = NodeSet.new(self) # TODO should also create new metadata!! end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Duxml::LazyOx
Instance Method Details
#to_s ⇒ Object
22 23 24 |
# File 'lib/duxml/doc.rb', line 22 def to_s "#<#{self.class.to_s} @object_id='#{object_id}' @root='#{root.nil? ? '' : root.description}'>" end |
#write_to(path) ⇒ Object
15 16 17 18 19 20 |
# File 'lib/duxml/doc.rb', line 15 def write_to(path) s = attributes.collect do |k, v| %( #{k}="#{v}") end.join %(<?xml #{s}?>)+nodes.first.to_s File.write(path, s) self end |