From ff6dc617dc7cda8994cb7dd67ef13233929c29b7 Mon Sep 17 00:00:00 2001 From: Guillaume DOTT Date: Tue, 10 Sep 2013 15:56:14 +0200 Subject: [PATCH] Remove support for string datetime in SMS --- lib/biju/sms.rb | 18 +++--------------- lib/biju/version.rb | 2 +- 2 files changed, 4 insertions(+), 16 deletions(-) diff --git a/lib/biju/sms.rb b/lib/biju/sms.rb index 97f55b5..3eaa5f0 100644 --- a/lib/biju/sms.rb +++ b/lib/biju/sms.rb @@ -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 diff --git a/lib/biju/version.rb b/lib/biju/version.rb index b7d77d9..006eb47 100644 --- a/lib/biju/version.rb +++ b/lib/biju/version.rb @@ -1,3 +1,3 @@ module Biju - VERSION = "0.0.2" + VERSION = '0.0.2' end