Class: ASPSMS::Request::Abstract

Inherits:
Object
  • Object
show all
Includes:
REXML
Defined in:
lib/aspsms.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(cfg) ⇒ Abstract

Returns a new instance of Abstract.



163
164
165
166
167
# File 'lib/aspsms.rb', line 163

def initialize(cfg)
  @cfg = cfg
  @userkey = @cfg.userkey
  @password = @cfg.password
end

Instance Attribute Details

#passwordObject

Returns the value of attribute password.



161
162
163
# File 'lib/aspsms.rb', line 161

def password
  @password
end

#userkeyObject

Returns the value of attribute userkey.



161
162
163
# File 'lib/aspsms.rb', line 161

def userkey
  @userkey
end

Instance Method Details

#to_sObject



169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
# File 'lib/aspsms.rb', line 169

def to_s
  doc = Document.new
  doc << REXML::XMLDecl.new('1.0', 'ISO-8859-1')
  root = Element.new('aspsms')
  root.elements.add(Element.new('Userkey').
                    add_text(@cfg.utf8(userkey)))
  root.elements.add(Element.new('Password').
                    add_text(@cfg.utf8(password)))
  each_element do |element|
    root.elements.add(element)
  end
  root.elements.add(Element.new('Action').
                    add_text(self.class.name.gsub(/^.*::/, '')))
  doc << root
  doc.to_s
end