Class: Gsm::Outgoing

Inherits:
Object
  • Object
show all
Defined in:
lib/rubygsm/msg/outgoing.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(device, recipient = nil, text = nil) ⇒ Outgoing

Returns a new instance of Outgoing.



9
10
11
12
13
14
15
16
17
18
19
# File 'lib/rubygsm/msg/outgoing.rb', line 9

def initialize(device, recipient=nil, text=nil)
	
	# check that the device is 
	#raise ArgumentError, "Invalid device"\
	#	unless device.respond_to?(:send_sms)
	
	# init the instance vars
	@recipient = recipient
	@device = device
	@text = text
end

Instance Attribute Details

#deviceObject (readonly)

Returns the value of attribute device.



7
8
9
# File 'lib/rubygsm/msg/outgoing.rb', line 7

def device
  @device
end

#recipientObject

Returns the value of attribute recipient.



6
7
8
# File 'lib/rubygsm/msg/outgoing.rb', line 6

def recipient
  @recipient
end

#sentObject (readonly)

Returns the value of attribute sent.



7
8
9
# File 'lib/rubygsm/msg/outgoing.rb', line 7

def sent
  @sent
end

#textObject

Returns the value of attribute text.



6
7
8
# File 'lib/rubygsm/msg/outgoing.rb', line 6

def text
  @text
end

Instance Method Details

#numberObject

Returns the recipient of this message, so incoming and outgoing messages can be logged in the same way.



33
34
35
# File 'lib/rubygsm/msg/outgoing.rb', line 33

def number
	recipient
end

#send!Object



21
22
23
24
25
26
27
28
# File 'lib/rubygsm/msg/outgoing.rb', line 21

def send!
	@device.send_sms(self)
	@sent = Time.now
	
	# once sent, allow no
	# more modifications
	freeze
end