Class: Voicemail::IntroMessageCreator

Inherits:
Object
  • Object
show all
Defined in:
lib/voicemail/intro_message_creator.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(message) ⇒ IntroMessageCreator

Returns a new instance of IntroMessageCreator.

Raises:

  • (ArgumentError)


11
12
13
14
# File 'lib/voicemail/intro_message_creator.rb', line 11

def initialize(message)
  raise ArgumentError, "MailboxPlayMessageIntroController needs a valid message passed to it" unless message
  @current_message = message
end

Instance Attribute Details

#current_messageObject

Returns the value of attribute current_message.



9
10
11
# File 'lib/voicemail/intro_message_creator.rb', line 9

def current_message
  @current_message
end

Instance Method Details

#from_messageObject



34
35
36
37
38
39
40
41
42
43
# File 'lib/voicemail/intro_message_creator.rb', line 34

def from_message
  case config.numeric_method
  when :i18n_string
    I18n.t "voicemail.messages.message_received_from_x", from: from_string
  when :play_numeric
    [config.messages.from, from_ssml]
  when :ahn_say
    [config.messages.from, Ahnsay.sounds_for_digits(from_digits)]
  end
end

#intro_messageObject



16
17
18
# File 'lib/voicemail/intro_message_creator.rb', line 16

def intro_message
  Array(time_message) + Array(from_message)
end

#time_messageObject



20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/voicemail/intro_message_creator.rb', line 20

def time_message
  case config.numeric_method
  when :i18n_string
    I18n.t "voicemail.messages.message_received_on_x", received_on: I18n.localize(current_message[:received])
  when :play_numeric
    [config.messages.message_received_on, time_ssml]
  when :ahn_say
    [
      config.messages.message_received_on,
      Ahnsay.sounds_for_time(current_message[:received], format: config.datetime_format)
    ]
  end
end