Class: SMS::Outgoing

Inherits:
Object
  • Object
show all
Defined in:
lib/rubysms/message/outgoing.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#backendObject (readonly)

Returns the value of attribute backend.



8
9
10
# File 'lib/rubysms/message/outgoing.rb', line 8

def backend
  @backend
end

#in_response_toObject

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

#recipientObject (readonly)

Returns the value of attribute recipient.



8
9
10
# File 'lib/rubysms/message/outgoing.rb', line 8

def recipient
  @recipient
end

#sentObject (readonly)

Returns the value of attribute sent.



8
9
10
# File 'lib/rubysms/message/outgoing.rb', line 8

def sent
  @sent
end

#textObject

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_numberObject

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