Class: Textris::Message
- Inherits:
-
Object
- Object
- Textris::Message
- Defined in:
- lib/textris/message.rb
Instance Attribute Summary collapse
-
#action ⇒ Object
readonly
Returns the value of attribute action.
-
#content ⇒ Object
readonly
Returns the value of attribute content.
-
#from_name ⇒ Object
readonly
Returns the value of attribute from_name.
-
#from_phone ⇒ Object
readonly
Returns the value of attribute from_phone.
-
#texter ⇒ Object
readonly
Returns the value of attribute texter.
-
#to ⇒ Object
readonly
Returns the value of attribute to.
Instance Method Summary collapse
- #deliver ⇒ Object
- #from ⇒ Object
-
#initialize(options = {}) ⇒ Message
constructor
A new instance of Message.
Constructor Details
#initialize(options = {}) ⇒ Message
Returns a new instance of Message.
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/textris/message.rb', line 5 def initialize( = {}) @to = parse_to [:to] @content = parse_content [:content] if .has_key?(:from) @from_name, @from_phone = parse_from [:from] else @from_name = [:from_name] @from_phone = [:from_phone] end unless @content.present? raise(ArgumentError, "Content must be provided") end unless @to.present? raise(ArgumentError, "Recipients must be provided and E.164 compilant") end @texter = [:texter] @action = [:action] end |
Instance Attribute Details
#action ⇒ Object (readonly)
Returns the value of attribute action.
3 4 5 |
# File 'lib/textris/message.rb', line 3 def action @action end |
#content ⇒ Object (readonly)
Returns the value of attribute content.
3 4 5 |
# File 'lib/textris/message.rb', line 3 def content @content end |
#from_name ⇒ Object (readonly)
Returns the value of attribute from_name.
3 4 5 |
# File 'lib/textris/message.rb', line 3 def from_name @from_name end |
#from_phone ⇒ Object (readonly)
Returns the value of attribute from_phone.
3 4 5 |
# File 'lib/textris/message.rb', line 3 def from_phone @from_phone end |
#texter ⇒ Object (readonly)
Returns the value of attribute texter.
3 4 5 |
# File 'lib/textris/message.rb', line 3 def texter @texter end |
#to ⇒ Object (readonly)
Returns the value of attribute to.
3 4 5 |
# File 'lib/textris/message.rb', line 3 def to @to end |
Instance Method Details
#deliver ⇒ Object
28 29 30 31 32 33 34 35 |
# File 'lib/textris/message.rb', line 28 def deliver deliveries = ::Textris::Delivery.get deliveries.each do |delivery| delivery.new(self).deliver_to_all end self end |
#from ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/textris/message.rb', line 43 def from if @from_phone.present? if @from_name.present? "#{@from_name} <#{Phony.format(@from_phone)}>" else Phony.format(@from_phone) end elsif @from_name.present? @from_name end end |