Class: ASPSMS::Gateway
- Inherits:
-
Object
- Object
- ASPSMS::Gateway
- Defined in:
- lib/aspsms.rb
Overview
Handles network communication with the ASPSMS gateways.
Instance Attribute Summary collapse
-
#host ⇒ Object
readonly
Returns the value of attribute host.
-
#port ⇒ Object
readonly
Returns the value of attribute port.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(cfg, gw) ⇒ Gateway
constructor
A new instance of Gateway.
- #send(req) ⇒ Object
Constructor Details
#initialize(cfg, gw) ⇒ Gateway
Returns a new instance of Gateway.
345 346 347 348 349 350 351 |
# File 'lib/aspsms.rb', line 345 def initialize(cfg, gw) @cfg = cfg if gw.match(/^(.*):([0-9]{1,5})$/) @host, @port = $1, $2 end @http = @cfg.http_class.new(host, port) end |
Instance Attribute Details
#host ⇒ Object (readonly)
Returns the value of attribute host.
331 332 333 |
# File 'lib/aspsms.rb', line 331 def host @host end |
#port ⇒ Object (readonly)
Returns the value of attribute port.
331 332 333 |
# File 'lib/aspsms.rb', line 331 def port @port end |
Class Method Details
.send(cfg, req) ⇒ Object
332 333 334 335 336 337 338 339 340 341 342 343 |
# File 'lib/aspsms.rb', line 332 def self.send(cfg, req) cfg.gateways.each do |spec| begin resp = Gateway.new(cfg, spec).send(req) return resp rescue # continue with next gateway in list # XXX collect exception objects and add to raise below end end raise 'Failed to send request to gateways!' end |