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
:yields: Document.
- #to_s ⇒ Object
Methods inherited from Node
Constructor Details
#initialize ⇒ Document
:yields: Document
55 56 57 58 59 60 61 |
# File 'lib/handsoap/xml_mason.rb', line 55 def initialize # :yields: Document super @document_element = nil if block_given? yield self end end |
Instance Method Details
#append_child(node) ⇒ Object
62 63 64 65 66 67 |
# File 'lib/handsoap/xml_mason.rb', line 62 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
77 78 79 |
# File 'lib/handsoap/xml_mason.rb', line 77 def defines_namespace?(prefix) false end |
#find(name) ⇒ Object
68 69 70 |
# File 'lib/handsoap/xml_mason.rb', line 68 def find(name) @document_element.find(name) end |
#find_all(name) ⇒ Object
71 72 73 |
# File 'lib/handsoap/xml_mason.rb', line 71 def find_all(name) @document_element.find_all(name) end |
#get_namespace(prefix) ⇒ Object
74 75 76 |
# File 'lib/handsoap/xml_mason.rb', line 74 def get_namespace(prefix) @namespaces[prefix] || raise("No alias registered for prefix '#{prefix}'") end |
#to_s ⇒ Object
80 81 82 83 84 85 |
# File 'lib/handsoap/xml_mason.rb', line 80 def to_s if @document_element.nil? raise "No document element added." end "<?xml version='1.0' ?>" + "\n" + @document_element.to_s end |