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