Class: Textris::Message

Inherits:
Object
  • Object
show all
Defined in:
lib/textris/message.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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(options = {})
  @to      = parse_to      options[:to]
  @content = parse_content options[:content]

  if options.has_key?(:from)
    @from_name, @from_phone = parse_from options[:from]
  else
    @from_name  = options[:from_name]
    @from_phone = options[: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 = options[:texter]
  @action = options[:action]
end

Instance Attribute Details

#actionObject (readonly)

Returns the value of attribute action.



3
4
5
# File 'lib/textris/message.rb', line 3

def action
  @action
end

#contentObject (readonly)

Returns the value of attribute content.



3
4
5
# File 'lib/textris/message.rb', line 3

def content
  @content
end

#from_nameObject (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_phoneObject (readonly)

Returns the value of attribute from_phone.



3
4
5
# File 'lib/textris/message.rb', line 3

def from_phone
  @from_phone
end

#texterObject (readonly)

Returns the value of attribute texter.



3
4
5
# File 'lib/textris/message.rb', line 3

def texter
  @texter
end

#toObject (readonly)

Returns the value of attribute to.



3
4
5
# File 'lib/textris/message.rb', line 3

def to
  @to
end

Instance Method Details

#deliverObject



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.send_message_to_all(self)
  end

  self
end