Remove support for string datetime in SMS

develop
Guillaume DOTT 2013-09-10 15:56:14 +02:00
parent f4218e1025
commit ff6dc617dc
2 changed files with 4 additions and 16 deletions

View File

@ -2,8 +2,7 @@ require 'date'
module Biju
class Sms
attr_accessor :id, :phone_number, :type_of_address, :message
attr_reader :datetime
attr_reader :id, :phone_number, :type_of_address, :message, :datetime
def self.from_pdu(string, id = nil)
sms_infos = PDU.decode(string)
@ -14,23 +13,12 @@ module Biju
message: sms_infos[:user_data].decode)
end
def initialize(params={})
def initialize(params = {})
params.each do |attr, value|
self.public_send("#{attr}=", value)
instance_variable_set(:"@#{attr}", value)
end if params
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
"[#{id}] (#{phone_number}) #{datetime} '#{message}'"
end

View File

@ -1,3 +1,3 @@
module Biju
VERSION = "0.0.2"
VERSION = '0.0.2'
end