Class: Handsoap::XmlMason::Document
- Defined in:
- lib/handsoap/xml_mason.rb
Instance Method Summary collapse
- #append_child(node) ⇒ Object
- #defines_namespace?(prefix) ⇒ Boolean
- #find(name) ⇒ Object
- #find_all(name) ⇒ Object
- #get_namespace(prefix) ⇒ Object
-
#initialize ⇒ Document
constructor
A new instance of Document.
- #to_s ⇒ Object
Methods inherited from Node
Constructor Details
#initialize ⇒ Document
Returns a new instance of Document.
39 40 41 42 43 44 45 |
# File 'lib/handsoap/xml_mason.rb', line 39 def initialize super @document_element = nil if block_given? yield self end end |
Instance Method Details
#append_child(node) ⇒ Object
46 47 48 49 50 51 |
# File 'lib/handsoap/xml_mason.rb', line 46 def append_child(node) if not @document_element.nil? raise "There can only be one element at the top level." end @document_element = node end |
#defines_namespace?(prefix) ⇒ Boolean
61 62 63 |
# File 'lib/handsoap/xml_mason.rb', line 61 def defines_namespace?(prefix) false end |
#find(name) ⇒ Object
52 53 54 |
# File 'lib/handsoap/xml_mason.rb', line 52 def find(name) @document_element.find(name) end |
#find_all(name) ⇒ Object
55 56 57 |
# File 'lib/handsoap/xml_mason.rb', line 55 def find_all(name) @document_element.find_all(name) end |
#get_namespace(prefix) ⇒ Object
58 59 60 |
# File 'lib/handsoap/xml_mason.rb', line 58 def get_namespace(prefix) @namespaces[prefix] || raise("No alias registered for prefix '#{prefix}'") end |
#to_s ⇒ Object
64 65 66 67 68 69 |
# File 'lib/handsoap/xml_mason.rb', line 64 def to_s if @document_element.nil? raise "No document element added." end "<?xml version='1.0' ?>" + "\n" + @document_element.to_s end |