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.



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

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

Instance Attribute Details

#passwordObject

Returns the value of attribute password.



158
159
160
# File 'lib/aspsms.rb', line 158

def password
  @password
end

#userkeyObject

Returns the value of attribute userkey.



158
159
160
# File 'lib/aspsms.rb', line 158

def userkey
  @userkey
end

Instance Method Details

#to_sObject



166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
# File 'lib/aspsms.rb', line 166

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