Class: Rumeme::SmsMessage
- Inherits:
-
Object
- Object
- Rumeme::SmsMessage
- Defined in:
- lib/rumeme/sms_message.rb
Overview
This class represents an SMS message.
Instance Attribute Summary collapse
-
#delay ⇒ Object
readonly
Returns the value of attribute delay.
-
#delivery_report ⇒ Object
readonly
Returns the value of attribute delivery_report.
-
#message ⇒ Object
readonly
Returns the value of attribute message.
-
#message_id ⇒ Object
readonly
Returns the value of attribute message_id.
-
#phone_number ⇒ Object
readonly
Returns the value of attribute phone_number.
-
#validity_period ⇒ Object
readonly
Returns the value of attribute validity_period.
Instance Method Summary collapse
-
#initialize(args) ⇒ SmsMessage
constructor
Constructor.
- #post_string ⇒ Object
Constructor Details
#initialize(args) ⇒ SmsMessage
Constructor.
7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/rumeme/sms_message.rb', line 7 def initialize args # this defaults must be moved to global configuration defaults = {:phone_number => nil, :message => nil, :message_id => 0, :delay => 0, :validity_period => ValidityPeriod::THREE_DAYS, :delivery_report => false} params = defaults.merge args defaults.keys.each {|key| instance_variable_set("@#{key.to_s}".to_sym, params[key])} raise ArgumentError.new("phone_number is empty") if @phone_number.nil? || @phone_number.empty? raise ArgumentError.new("message is empty") if @message.nil? || @message.empty? @message = @message.gsub("\n",'\n').gsub("\r",'\r').gsub("\\",'\\\\') end |
Instance Attribute Details
#delay ⇒ Object (readonly)
Returns the value of attribute delay.
4 5 6 |
# File 'lib/rumeme/sms_message.rb', line 4 def delay @delay end |
#delivery_report ⇒ Object (readonly)
Returns the value of attribute delivery_report.
4 5 6 |
# File 'lib/rumeme/sms_message.rb', line 4 def delivery_report @delivery_report end |
#message ⇒ Object (readonly)
Returns the value of attribute message.
4 5 6 |
# File 'lib/rumeme/sms_message.rb', line 4 def @message end |
#message_id ⇒ Object (readonly)
Returns the value of attribute message_id.
4 5 6 |
# File 'lib/rumeme/sms_message.rb', line 4 def @message_id end |
#phone_number ⇒ Object (readonly)
Returns the value of attribute phone_number.
4 5 6 |
# File 'lib/rumeme/sms_message.rb', line 4 def phone_number @phone_number end |
#validity_period ⇒ Object (readonly)
Returns the value of attribute validity_period.
4 5 6 |
# File 'lib/rumeme/sms_message.rb', line 4 def validity_period @validity_period end |
Instance Method Details
#post_string ⇒ Object
19 20 21 |
# File 'lib/rumeme/sms_message.rb', line 19 def post_string "#{@message_id} #{@phone_number} #{@delay} #{@validity_period} #{@delivery_report ? 1 : 0} #{@message}\r\n" end |