Class: SMS::Outgoing
- Inherits:
-
Object
- Object
- SMS::Outgoing
- Defined in:
- lib/rubysms/message/outgoing.rb
Instance Attribute Summary collapse
-
#backend ⇒ Object
readonly
Returns the value of attribute backend.
-
#in_response_to ⇒ Object
Returns the value of attribute in_response_to.
-
#recipient ⇒ Object
readonly
Returns the value of attribute recipient.
-
#sent ⇒ Object
readonly
Returns the value of attribute sent.
-
#text ⇒ Object
Returns the value of attribute text.
Instance Method Summary collapse
-
#initialize(backend, recipient = nil, text = nil) ⇒ Outgoing
constructor
A new instance of Outgoing.
-
#phone_number ⇒ Object
Returns the phone number of the recipient of this message.
-
#send! ⇒ Object
Sends the message via _@backend_ NOW, and prevents any further modifications to self, to avoid the object misrepresenting reality.
Constructor Details
#initialize(backend, recipient = nil, text = nil) ⇒ Outgoing
Returns a new instance of Outgoing.
10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/rubysms/message/outgoing.rb', line 10 def initialize(backend, recipient=nil, text=nil) # move all arguments into instance # vars, to be accessed by accessors @backend = backend @text = text # Sets @recipient, transforming _recipient_ into an SMS::Person if # it isn't already (to enable persistance between :Outgoing and/or # SMS::Incoming objects) @recipient = recipient.is_a?(SMS::Person) ? recipient : SMS::Person.fetch(backend, recipient) end |
Instance Attribute Details
#backend ⇒ Object (readonly)
Returns the value of attribute backend.
8 9 10 |
# File 'lib/rubysms/message/outgoing.rb', line 8 def backend @backend end |
#in_response_to ⇒ Object
Returns the value of attribute in_response_to.
7 8 9 |
# File 'lib/rubysms/message/outgoing.rb', line 7 def in_response_to @in_response_to end |
#recipient ⇒ Object (readonly)
Returns the value of attribute recipient.
8 9 10 |
# File 'lib/rubysms/message/outgoing.rb', line 8 def recipient @recipient end |
#sent ⇒ Object (readonly)
Returns the value of attribute sent.
8 9 10 |
# File 'lib/rubysms/message/outgoing.rb', line 8 def sent @sent end |
#text ⇒ Object
Returns the value of attribute text.
7 8 9 |
# File 'lib/rubysms/message/outgoing.rb', line 7 def text @text end |
Instance Method Details
#phone_number ⇒ Object
Returns the phone number of the recipient of this message.
36 37 38 |
# File 'lib/rubysms/message/outgoing.rb', line 36 def phone_number recipient.phone_number end |
#send! ⇒ Object
Sends the message via _@backend_ NOW, and prevents any further modifications to self, to avoid the object misrepresenting reality.
26 27 28 29 30 31 32 33 |
# File 'lib/rubysms/message/outgoing.rb', line 26 def send! backend.send_sms(self) @sent = Time.now # once sent, allow no # more modifications freeze end |