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
62
# File 'lib/handsoap/xml_mason.rb', line 55

def initialize # :yields: Document
  super
  @document_element = nil
  @xml_header = true
  if block_given?
    yield self
  end
end

Instance Method Details

#append_child(node) ⇒ Object



66
67
68
69
70
71
# File 'lib/handsoap/xml_mason.rb', line 66

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



81
82
83
# File 'lib/handsoap/xml_mason.rb', line 81

def defines_namespace?(prefix)
  false
end

#find(name) ⇒ Object



72
73
74
# File 'lib/handsoap/xml_mason.rb', line 72

def find(name)
  @document_element.find(name)
end

#find_all(name) ⇒ Object



75
76
77
# File 'lib/handsoap/xml_mason.rb', line 75

def find_all(name)
  @document_element.find_all(name)
end

#get_namespace(prefix) ⇒ Object



78
79
80
# File 'lib/handsoap/xml_mason.rb', line 78

def get_namespace(prefix)
  @namespaces[prefix] || raise("No alias registered for prefix '#{prefix}'")
end

#to_sObject



84
85
86
87
88
89
# File 'lib/handsoap/xml_mason.rb', line 84

def to_s
  if @document_element.nil?
    raise "No document element added."
  end
  (@xml_header ? "<?xml version='1.0' ?>\n" : "") + @document_element.to_s
end

#xml_header=(xml_header) ⇒ Object



63
64
65
# File 'lib/handsoap/xml_mason.rb', line 63

def xml_header=(xml_header)
  @xml_header = !! xml_header
end