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

- (Document) initialize

: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

- (Object) append_child(node)



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

- (Boolean) defines_namespace?(prefix)



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

def defines_namespace?(prefix)
  false
end

- (Object) find(name)



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

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

- (Object) find_all(name)



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

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

- (Object) get_namespace(prefix)



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

- (Object) to_s



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

- (Object) xml_header=(xml_header)



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

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