Sha256: 954e9157e37cd83a3db7e860de1932f64867de799ef6f489c51b061f9dc0a9b9

Contents?: true

Size: 1.13 KB

Versions: 4

Compression:

Stored size: 1.13 KB

Contents

module Voicemail
  class MailboxController < ApplicationController

    attr_accessor :new_or_saved

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

    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

    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

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

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
voicemail-1.1.1 lib/voicemail/call_controllers/mailbox_controller.rb
voicemail-1.1.0 lib/voicemail/call_controllers/mailbox_controller.rb
voicemail-1.0.0 lib/voicemail/call_controllers/mailbox_controller.rb
voicemail-1.0.0.beta lib/voicemail/call_controllers/mailbox_controller.rb