blob: ef13bc42a9d2122a5196e124d1cdfb379a0ebf19 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
require 'smswsc/builder'
require 'rexml/document'
module SMSWSC
class PhonebookEntry
attr_accessor :name
attr_accessor :addr_type
attr_accessor :addr
attr_accessor :uri
def initialize(options = {})
@addr_type = options["addr-type"]
@addr = options["addr"]
@name = options["name"]
end
def uri=(value)
@uri = value
end
def self.load_xml(parent)
entry = PhonebookEntry.new
parent.each_element do |element|
case element.name
when "addr-type"
entry.addr_type = element.text.to_s
when "addr"
entry.addr = element.text.to_s
when "name"
entry.name = element.text.to_s
when "uri"
entry.uri = URI.parse(element.text.to_s)
end
end
return entry
end
def to_xml(builder = nil, element = "phonebook-entry")
xml = ""
unless builder
builder = SMSWSC.new_builder(xml)
end
builder.tag!(element.to_s) {
builder.tag! "addr-type", @addr_type
builder.tag! "addr", @addr
builder.tag! "name", @name
}
return xml
end
end
end
|