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.



6
7
8
9
10
11
12
13
14
15
# File 'lib/textris/message.rb', line 6

def initialize(options = {})
  initialize_content(options)
  initialize_author(options)
  initialize_recipients(options)

  @texter     = options[:texter]
  @action     = options[:action]
  @args       = options[:args]
  @media_urls = options[:media_urls]
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

#argsObject (readonly)

Returns the value of attribute args.



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

def args
  @args
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

#media_urlsObject (readonly)

Returns the value of attribute media_urls.



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

def media_urls
  @media_urls
end

#texter(options = {}) ⇒ Object (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

#twilio_messaging_service_sidObject (readonly)

Returns the value of attribute twilio_messaging_service_sid.



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

def twilio_messaging_service_sid
  @twilio_messaging_service_sid
end

Instance Method Details

#deliverObject



17
18
19
20
21
22
23
24
# File 'lib/textris/message.rb', line 17

def deliver
  deliveries = ::Textris::Delivery.get
  deliveries.each do |delivery|
    delivery.new(self).deliver_to_all
  end

  self
end

#fromObject



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/textris/message.rb', line 34

def from
  if @from_phone.present?
    if @from_name.present?
      if PhoneFormatter.is_alphameric?(@from_phone)
        @from_phone
      else
        if PhoneFormatter.is_a_short_code?(@from_phone)
          "#{@from_name} <#{@from_phone}>"
        else
          "#{@from_name} <#{Phony.format(@from_phone)}>"
        end
      end
    else
      Phony.format(@from_phone)
    end
  elsif @from_name.present?
    @from_name
  end
end