Class: Smess::Sms
- Inherits:
-
Object
- Object
- Smess::Sms
- Defined in:
- lib/smess/sms.rb
Instance Attribute Summary collapse
-
#message ⇒ Object
Returns the value of attribute message.
-
#originator ⇒ Object
Returns the value of attribute originator.
-
#output ⇒ Object
Returns the value of attribute output.
-
#results ⇒ Object
Returns the value of attribute results.
-
#to ⇒ Object
Returns the value of attribute to.
Instance Method Summary collapse
- #check(code) ⇒ Object
- #deliver ⇒ Object
- #delivered? ⇒ Boolean
-
#initialize(*args) ⇒ Sms
constructor
A new instance of Sms.
- #send_feedback(to, message_sid) ⇒ Object
- #verify(using: 'sms') ⇒ Object
Constructor Details
#initialize(*args) ⇒ Sms
Returns a new instance of Sms.
6 7 8 9 10 11 12 |
# File 'lib/smess/sms.rb', line 6 def initialize(*args) opts = args.first || {} @to = opts.fetch(:to, nil) @message = opts.fetch(:message, "") @originator = opts.fetch(:originator, nil) @output = opts.fetch(:output, :auto).to_sym end |
Instance Attribute Details
#message ⇒ Object
Returns the value of attribute message.
4 5 6 |
# File 'lib/smess/sms.rb', line 4 def @message end |
#originator ⇒ Object
Returns the value of attribute originator.
4 5 6 |
# File 'lib/smess/sms.rb', line 4 def originator @originator end |
#output ⇒ Object
Returns the value of attribute output.
4 5 6 |
# File 'lib/smess/sms.rb', line 4 def output @output end |
#results ⇒ Object
Returns the value of attribute results.
4 5 6 |
# File 'lib/smess/sms.rb', line 4 def results @results end |
#to ⇒ Object
Returns the value of attribute to.
4 5 6 |
# File 'lib/smess/sms.rb', line 4 def to @to end |
Instance Method Details
#check(code) ⇒ Object
26 27 28 29 30 |
# File 'lib/smess/sms.rb', line 26 def check(code) out = Smess.named_output_instance(output) out.sms = self self.results = {sent_with: output}.merge(out.check(code)) end |
#deliver ⇒ Object
14 15 16 17 18 |
# File 'lib/smess/sms.rb', line 14 def deliver out = Smess.named_output_instance(output) out.sms = self self.results = {sent_with: output}.merge(out.deliver) end |
#delivered? ⇒ Boolean
32 33 34 |
# File 'lib/smess/sms.rb', line 32 def delivered? results[:response_code] == "0" end |
#send_feedback(to, message_sid) ⇒ Object
36 37 38 39 40 41 |
# File 'lib/smess/sms.rb', line 36 def send_feedback(to, ) out = Smess.named_output_instance(output) @to = to out.sms = self out.send_feedback() end |
#verify(using: 'sms') ⇒ Object
20 21 22 23 24 |
# File 'lib/smess/sms.rb', line 20 def verify(using: 'sms') out = Smess.named_output_instance(output) out.sms = self self.results = {sent_with: output}.merge(out.verify(using: using)) end |