Class: Handsoap::XmlMason::Document

Inherits:
Node
  • Object
show all
Defined in:
lib/handsoap/xml_mason.rb

Instance Method Summary collapse

Methods inherited from Node

#add, #alias

Constructor Details

#initializeDocument

: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_sObject



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