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



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

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

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

#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

Instance Method Details

#deliverObject



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

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

  self
end

#fromObject



32
33
34
35
36
37
38
39
40
41
42
# File 'lib/textris/message.rb', line 32

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