Remove support for string datetime in SMS
parent
f4218e1025
commit
ff6dc617dc
|
@ -2,8 +2,7 @@ require 'date'
|
||||||
|
|
||||||
module Biju
|
module Biju
|
||||||
class Sms
|
class Sms
|
||||||
attr_accessor :id, :phone_number, :type_of_address, :message
|
attr_reader :id, :phone_number, :type_of_address, :message, :datetime
|
||||||
attr_reader :datetime
|
|
||||||
|
|
||||||
def self.from_pdu(string, id = nil)
|
def self.from_pdu(string, id = nil)
|
||||||
sms_infos = PDU.decode(string)
|
sms_infos = PDU.decode(string)
|
||||||
|
@ -14,23 +13,12 @@ module Biju
|
||||||
message: sms_infos[:user_data].decode)
|
message: sms_infos[:user_data].decode)
|
||||||
end
|
end
|
||||||
|
|
||||||
def initialize(params={})
|
def initialize(params = {})
|
||||||
params.each do |attr, value|
|
params.each do |attr, value|
|
||||||
self.public_send("#{attr}=", value)
|
instance_variable_set(:"@#{attr}", value)
|
||||||
end if params
|
end if params
|
||||||
end
|
end
|
||||||
|
|
||||||
def datetime=(arg)
|
|
||||||
@datetime = case arg
|
|
||||||
when String
|
|
||||||
DateTime.strptime(arg, "%y/%m/%d,%T%Z")
|
|
||||||
when DateTime
|
|
||||||
arg
|
|
||||||
else
|
|
||||||
nil
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def to_s
|
def to_s
|
||||||
"[#{id}] (#{phone_number}) #{datetime} '#{message}'"
|
"[#{id}] (#{phone_number}) #{datetime} '#{message}'"
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,3 +1,3 @@
|
||||||
module Biju
|
module Biju
|
||||||
VERSION = "0.0.2"
|
VERSION = '0.0.2'
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue