Class: Telesms::Outgoing
- Inherits:
-
Object
- Object
- Telesms::Outgoing
- Extended by:
- Base
- Defined in:
- lib/telesms/outgoing.rb
Overview
This class represents an outgoing message.
Instance Attribute Summary collapse
-
#from ⇒ String
The FROM address.
-
#message ⇒ String
The message body being sent.
-
#provider ⇒ String
The provider for the number.
-
#to ⇒ String
The TO address (will be concatinated with a provider).
Class Method Summary collapse
-
.deliver(from, to, provider, message) ⇒ Mail
This method creates a new outgoing message and sends it.
Instance Method Summary collapse
-
#deliver ⇒ Mail
This method sends an email message disguised as an SMS message.
-
#formatted_to ⇒ String
This method formats the TO address to include the provider.
-
#initialize(from, to, provider, message) ⇒ Outgoing
constructor
This method creates a new outgoing message.
-
#sanitized_message ⇒ String
This method sanitizes the message body.
Methods included from Base
Constructor Details
#initialize(from, to, provider, message) ⇒ Outgoing
This method creates a new outgoing message.
56 57 58 59 60 61 |
# File 'lib/telesms/outgoing.rb', line 56 def initialize(from, to, provider, ) @from = from @to = to @provider = provider @message = end |
Instance Attribute Details
#from ⇒ String
The FROM address.
8 9 10 |
# File 'lib/telesms/outgoing.rb', line 8 def from @from end |
#message ⇒ String
The message body being sent.
20 21 22 |
# File 'lib/telesms/outgoing.rb', line 20 def @message end |
#provider ⇒ String
The provider for the number.
16 17 18 |
# File 'lib/telesms/outgoing.rb', line 16 def provider @provider end |
#to ⇒ String
The TO address (will be concatinated with a provider).
12 13 14 |
# File 'lib/telesms/outgoing.rb', line 12 def to @to end |
Class Method Details
.deliver(from, to, provider, message) ⇒ Mail
This method creates a new outgoing message and sends it.
37 38 39 |
# File 'lib/telesms/outgoing.rb', line 37 def self.deliver(from, to, provider, ) self.new(from, to, provider, ).deliver end |
Instance Method Details
#deliver ⇒ Mail
This method sends an email message disguised as an SMS message.
66 67 68 |
# File 'lib/telesms/outgoing.rb', line 66 def deliver Mail.new(from: from, to: formatted_to, body: ).deliver! end |
#formatted_to ⇒ String
This method formats the TO address to include the provider.
73 74 75 |
# File 'lib/telesms/outgoing.rb', line 73 def formatted_to "#{to}@#{Base.gateways[@provider][:sms]}" rescue raise "Invalid provider" end |
#sanitized_message ⇒ String
This method sanitizes the message body.
80 81 82 |
# File 'lib/telesms/outgoing.rb', line 80 def .to_s[0,140] end |