Class: BabySMS::Message
- Inherits:
-
Object
- Object
- BabySMS::Message
- Defined in:
- lib/babysms/message.rb
Instance Attribute Summary collapse
-
#contents ⇒ Object
Returns the value of attribute contents.
-
#from ⇒ Object
Returns the value of attribute from.
-
#to ⇒ Object
Returns the value of attribute to.
Instance Method Summary collapse
- #deliver(adapters: BabySMS.adapters, strategy: BabySMS.strategy) ⇒ Object
-
#initialize(to:, from: nil, contents:, uuid: nil) ⇒ Message
constructor
A new instance of Message.
-
#reply(contents:, adapters: BabySMS.adapters, strategy: BabySMS.strategy) ⇒ Object
generates and delivers a reply to a message.
Constructor Details
#initialize(to:, from: nil, contents:, uuid: nil) ⇒ Message
Returns a new instance of Message.
10 11 12 13 14 |
# File 'lib/babysms/message.rb', line 10 def initialize(to:, from: nil, contents:, uuid: nil) @to = Phony.normalize(to) @from = from @contents = contents end |
Instance Attribute Details
#contents ⇒ Object
Returns the value of attribute contents.
8 9 10 |
# File 'lib/babysms/message.rb', line 8 def contents @contents end |
#from ⇒ Object
Returns the value of attribute from.
7 8 9 |
# File 'lib/babysms/message.rb', line 7 def from @from end |
#to ⇒ Object
Returns the value of attribute to.
6 7 8 |
# File 'lib/babysms/message.rb', line 6 def to @to end |
Instance Method Details
#deliver(adapters: BabySMS.adapters, strategy: BabySMS.strategy) ⇒ Object
16 17 18 19 |
# File 'lib/babysms/message.rb', line 16 def deliver(adapters: BabySMS.adapters, strategy: BabySMS.strategy) validate! BabySMS::MailMan.new(adapters: adapters, strategy: strategy).deliver(self) end |
#reply(contents:, adapters: BabySMS.adapters, strategy: BabySMS.strategy) ⇒ Object
generates and delivers a reply to a message
22 23 24 25 |
# File 'lib/babysms/message.rb', line 22 def reply(contents:, adapters: BabySMS.adapters, strategy: BabySMS.strategy) Message.new(to: from, from: to, contents: contents) .deliver(adapters: adapters, strategy: strategy) end |