Class: ComunikaGsm::PDU::PDUDecode
- Inherits:
-
Object
- Object
- ComunikaGsm::PDU::PDUDecode
- Defined in:
- lib/comunika_gsm/pdu.rb
Instance Attribute Summary collapse
-
#connection ⇒ Object
Returns the value of attribute connection.
-
#id ⇒ Object
Returns the value of attribute id.
-
#length ⇒ Object
Returns the value of attribute length.
-
#message ⇒ Object
Returns the value of attribute message.
-
#mlenght ⇒ Object
Returns the value of attribute mlenght.
- #mtype ⇒ Object
-
#number ⇒ Object
Returns the value of attribute number.
-
#pdu ⇒ Object
Returns the value of attribute pdu.
- #receipt_at ⇒ Object
- #sent_at ⇒ Object
-
#size ⇒ Object
Returns the value of attribute size.
-
#sms_id ⇒ Object
Returns the value of attribute sms_id.
-
#smsc ⇒ Object
Returns the value of attribute smsc.
-
#status ⇒ Object
Returns the value of attribute status.
-
#tp_dcs_popis ⇒ Object
Returns the value of attribute tp_dcs_popis.
-
#tp_pid ⇒ Object
Returns the value of attribute tp_pid.
-
#validity ⇒ Object
Returns the value of attribute validity.
Instance Method Summary collapse
- #decode ⇒ Object
- #delete ⇒ Object
-
#initialize(params) ⇒ PDUDecode
constructor
A new instance of PDUDecode.
Constructor Details
#initialize(params) ⇒ PDUDecode
Returns a new instance of PDUDecode.
24 25 26 27 28 29 30 |
# File 'lib/comunika_gsm/pdu.rb', line 24 def initialize(params) @id = params[:id]; @size = params[:size]; @pdu = params[:pdu]; @mtype = params[:mtype]; @smsc = params[:smsc] @number = params[:number]; @sms_id = params[:sms_id]; @sent_at = params[:sent_at]; @discharge_at = params[:receipt_at] @status = params[:status]; @tp_pid = params[:tp_pid]; @tp_dcs_popis = params[:tp_dcs_popis]; @message = params[:message] @length = params[:mlength]; @validity = params[:validity]; @mtype = params[:mtype] @connection = params[:connection] end |
Instance Attribute Details
#connection ⇒ Object
Returns the value of attribute connection.
21 22 23 |
# File 'lib/comunika_gsm/pdu.rb', line 21 def connection @connection end |
#id ⇒ Object
Returns the value of attribute id.
21 22 23 |
# File 'lib/comunika_gsm/pdu.rb', line 21 def id @id end |
#length ⇒ Object
Returns the value of attribute length.
21 22 23 |
# File 'lib/comunika_gsm/pdu.rb', line 21 def length @length end |
#message ⇒ Object
Returns the value of attribute message.
21 22 23 |
# File 'lib/comunika_gsm/pdu.rb', line 21 def @message end |
#mlenght ⇒ Object
Returns the value of attribute mlenght.
21 22 23 |
# File 'lib/comunika_gsm/pdu.rb', line 21 def mlenght @mlenght end |
#mtype ⇒ Object
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/comunika_gsm/pdu.rb', line 45 def mtype case @mtype when 'Receipt requested' 'INCOMING' when 'Status Report' 'REPORT' when 'Unknown Message' 'REPORT' when 'Receive message' 'INCOMING' when 'Data Header' 'MULTIPART' else 'UNKNOWN' end end |
#number ⇒ Object
Returns the value of attribute number.
21 22 23 |
# File 'lib/comunika_gsm/pdu.rb', line 21 def number @number end |
#pdu ⇒ Object
Returns the value of attribute pdu.
21 22 23 |
# File 'lib/comunika_gsm/pdu.rb', line 21 def pdu @pdu end |
#receipt_at ⇒ Object
41 42 43 |
# File 'lib/comunika_gsm/pdu.rb', line 41 def receipt_at Time.parse(@receipt_at.sub(/(\d+)\D+(\d+)\D+(\d+)/, '\1/\2/20\3')).strftime('%Y/%m/%d %H:%M:%S') rescue nil end |
#sent_at ⇒ Object
37 38 39 |
# File 'lib/comunika_gsm/pdu.rb', line 37 def sent_at Time.parse(@sent_at.sub(/(\d+)\D+(\d+)\D+(\d+)/, '\1/\2/20\3')).strftime('%Y/%m/%d %H:%M:%S') rescue nil end |
#size ⇒ Object
Returns the value of attribute size.
21 22 23 |
# File 'lib/comunika_gsm/pdu.rb', line 21 def size @size end |
#sms_id ⇒ Object
Returns the value of attribute sms_id.
21 22 23 |
# File 'lib/comunika_gsm/pdu.rb', line 21 def sms_id @sms_id end |
#smsc ⇒ Object
Returns the value of attribute smsc.
21 22 23 |
# File 'lib/comunika_gsm/pdu.rb', line 21 def smsc @smsc end |
#status ⇒ Object
Returns the value of attribute status.
21 22 23 |
# File 'lib/comunika_gsm/pdu.rb', line 21 def status @status end |
#tp_dcs_popis ⇒ Object
Returns the value of attribute tp_dcs_popis.
21 22 23 |
# File 'lib/comunika_gsm/pdu.rb', line 21 def tp_dcs_popis @tp_dcs_popis end |
#tp_pid ⇒ Object
Returns the value of attribute tp_pid.
21 22 23 |
# File 'lib/comunika_gsm/pdu.rb', line 21 def tp_pid @tp_pid end |
#validity ⇒ Object
Returns the value of attribute validity.
21 22 23 |
# File 'lib/comunika_gsm/pdu.rb', line 21 def validity @validity end |
Instance Method Details
#decode ⇒ Object
32 33 34 35 |
# File 'lib/comunika_gsm/pdu.rb', line 32 def decode PDU.decode(self.pdu).each {|k,v| instance_variable_set("@#{k.to_s}",v)} self end |
#delete ⇒ Object
62 63 64 |
# File 'lib/comunika_gsm/pdu.rb', line 62 def delete @connection.cmd("AT+CMGD=#{@id}\r\n") end |