Class: Lokii::GsmProxy
- Inherits:
-
Object
- Object
- Lokii::GsmProxy
- Defined in:
- lib/lokii/servers/gsm_proxy.rb
Overview
Messages come into the GsmModem based on its own set of intervals (or with another command for certain gsm modems). Because of that we need to proxy the callbacks and collect them on a per modem basis
Instance Attribute Summary collapse
-
#modem ⇒ Object
readonly
Returns the value of attribute modem.
-
#received ⇒ Object
Returns the value of attribute received.
Instance Method Summary collapse
- #incoming(message) ⇒ Object
-
#initialize(modem) ⇒ GsmProxy
constructor
A new instance of GsmProxy.
- #messages ⇒ Object
- #outgoing(number, text) ⇒ Object
Constructor Details
#initialize(modem) ⇒ GsmProxy
Returns a new instance of GsmProxy.
14 15 16 17 |
# File 'lib/lokii/servers/gsm_proxy.rb', line 14 def initialize(modem) @received = Array.new @modem = modem end |
Instance Attribute Details
#modem ⇒ Object (readonly)
Returns the value of attribute modem.
12 13 14 |
# File 'lib/lokii/servers/gsm_proxy.rb', line 12 def modem @modem end |
#received ⇒ Object
Returns the value of attribute received.
11 12 13 |
# File 'lib/lokii/servers/gsm_proxy.rb', line 11 def received @received end |
Instance Method Details
#incoming(message) ⇒ Object
19 20 21 |
# File 'lib/lokii/servers/gsm_proxy.rb', line 19 def incoming() @received << end |
#messages ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/lokii/servers/gsm_proxy.rb', line 27 def @modem.process(method(:incoming)) current = @received.dup @received.clear current.map {|m| {:phone => m.device, :number => m.sender, :text => m.text, :created_at => Time.parse("#{m.sent}"), :processed_at => Time.parse("#{m.received}")} } end |
#outgoing(number, text) ⇒ Object
23 24 25 |
# File 'lib/lokii/servers/gsm_proxy.rb', line 23 def outgoing(number, text) @modem.send_sms(number, text) end |