Class: Voicemail::MailboxController

Inherits:
ApplicationController show all
Defined in:
lib/voicemail/call_controllers/mailbox_controller.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from ApplicationController

#main_menu

Instance Attribute Details

#new_or_savedObject

Returns the value of attribute new_or_saved.



4
5
6
# File 'lib/voicemail/call_controllers/mailbox_controller.rb', line 4

def new_or_saved
  @new_or_saved
end

Instance Method Details

#get_countObject



42
43
44
# File 'lib/voicemail/call_controllers/mailbox_controller.rb', line 42

def get_count
  @number = storage.send "count_#{new_or_saved}_messages", mailbox[:id]
end

#play_message_countObject



27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/voicemail/call_controllers/mailbox_controller.rb', line 27

def play_message_count
  case config.numeric_method
  when :i18n_string
    play I18n.t("voicemail.mailbox.x_#{new_or_saved}_messages", count: @number)
  when :play_numeric
    play config.mailbox.number_before
    play_numeric @number
    play config.mailbox["number_after_#{new_or_saved}".to_sym]
  when :ahn_say
    play config.mailbox.number_before
    play *sounds_for_number(@number)
    play config.mailbox["number_after_#{new_or_saved}".to_sym]
  end
end

#play_number_of_messages(new_or_saved) ⇒ Object



16
17
18
19
20
21
22
23
24
25
# File 'lib/voicemail/call_controllers/mailbox_controller.rb', line 16

def play_number_of_messages(new_or_saved)
  @new_or_saved = new_or_saved
  get_count

  if @number > 0
    play_message_count
  else
    play config.messages["no_#{new_or_saved}_messages".to_sym]
  end
end

#runObject



6
7
8
9
10
11
12
13
14
# File 'lib/voicemail/call_controllers/mailbox_controller.rb', line 6

def run
  if mailbox
    play_number_of_messages :new
    play_number_of_messages :saved
    main_menu
  else
    mailbox_not_found
  end
end