Class: Adhearsion::Asterisk::ConfigGenerator::Queues::QueueDefinition

Inherits:
Adhearsion::Asterisk::ConfigGenerator show all
Defined in:
lib/adhearsion/asterisk/config_generator/queues.rb

Constant Summary

DEFAULT_QUEUE_PROPERTIES =
{
  :autofill          => 'yes',
  :eventwhencalled   => 'vars',
  :eventmemberstatus => 'yes',
  :setinterfacevar   => 'yes'
}
SUPPORTED_RING_STRATEGIES =
[:ringall, :roundrobin, :leastrecent, :fewestcalls, :random, :rrmemory]
DEFAULT_SOUND_FILES =
{
  'queue-youarenext'   => 'queue-youarenext',
  'queue-thereare'     => 'queue-thereare',
  'queue-callswaiting' => 'queue-callswaiting',
  'queue-holdtime'     => 'queue-holdtime',
  'queue-minutes'      => 'queue-minutes',
  'queue-seconds'      => 'queue-seconds',
  'queue-thankyou'     => 'queue-thankyou',
  'queue-lessthan'     => 'queue-less-than',
  'queue-reporthold'   => 'queue-reporthold',
  'periodic-announce'  => 'queue-periodic-announce'
}
SOUND_FILE_SYMBOL_INTERPRETATIONS =
{
  :you_are_next           => 'queue-youarenext',
  :there_are              => 'queue-thereare',
  :calls_waiting          => 'queue-callswaiting',
  :hold_time              => 'queue-holdtime',
  :minutes                => 'queue-minutes',
  :seconds                => 'queue-seconds',
  :thank_you              => 'queue-thankyou',
  :less_than              => 'queue-lessthan',
  :report_hold            => 'queue-reporthold',
  :periodic_announcement  => 'periodic-announce'
}

Constants inherited from Adhearsion::Asterisk::ConfigGenerator

SECTION_TITLE

Instance Attribute Summary (collapse)

Instance Method Summary (collapse)

Methods inherited from Adhearsion::Asterisk::ConfigGenerator

create_sanitary_hash_from, #to_sanitary_hash, warning_message

Constructor Details

- (QueueDefinition) initialize(name)



86
87
88
89
90
91
# File 'lib/adhearsion/asterisk/config_generator/queues.rb', line 86

def initialize(name)
  @name        = name
  @members     = []
  @properties  = DEFAULT_QUEUE_PROPERTIES.clone
  @sound_files = DEFAULT_SOUND_FILES.clone
end

Instance Attribute Details

- (Object) members (readonly)

Returns the value of attribute members



85
86
87
# File 'lib/adhearsion/asterisk/config_generator/queues.rb', line 85

def members
  @members
end

- (Object) name (readonly)

Returns the value of attribute name



85
86
87
# File 'lib/adhearsion/asterisk/config_generator/queues.rb', line 85

def name
  @name
end

- (Object) properties (readonly)

Returns the value of attribute properties



85
86
87
# File 'lib/adhearsion/asterisk/config_generator/queues.rb', line 85

def properties
  @properties
end

Instance Method Details

- (Object) announce_hold_time(seconds)



165
166
167
# File 'lib/adhearsion/asterisk/config_generator/queues.rb', line 165

def announce_hold_time(seconds)
  one_of [true, false, :once], "announce-holdtime" => seconds
end

- (Object) announce_round_seconds(yes_no_or_once)



169
170
171
# File 'lib/adhearsion/asterisk/config_generator/queues.rb', line 169

def announce_round_seconds(yes_no_or_once)
  int "announce-round-seconds" => yes_no_or_once
end

- (Object) autopause(yes_no)



146
147
148
# File 'lib/adhearsion/asterisk/config_generator/queues.rb', line 146

def autopause(yes_no)
  boolean :autopause => yes_no
end

- (Object) delay_connection_by(seconds)

Number of seconds to wait when an agent is to be bridged with a caller. Normally you'd want this to be zero.



202
203
204
# File 'lib/adhearsion/asterisk/config_generator/queues.rb', line 202

def delay_connection_by(seconds)
  int :memberdelay => seconds
end

- (Object) exit_to_context_on_digit_press(context_name)

A context may be specified, in which if the user types a SINGLE digit extension while they are in the queue, they will be taken out of the queue and sent to that extension in this context. This context should obviously be a different context other than the one that normally forwards to Adhearsion (though the context that handles these digits should probably go out to Adhearsion too).



121
122
123
# File 'lib/adhearsion/asterisk/config_generator/queues.rb', line 121

def exit_to_context_on_digit_press(context_name)
  string :context => context_name
end

- (Object) join_empty(yes_no_or_strict)

Ex: join_empty true Ex: join_empty :strict



184
185
186
# File 'lib/adhearsion/asterisk/config_generator/queues.rb', line 184

def join_empty(yes_no_or_strict)
  one_of [true, false, :strict], :joinempty => yes_no_or_strict
end

- (Object) leave_when_empty(yes_no)



188
189
190
# File 'lib/adhearsion/asterisk/config_generator/queues.rb', line 188

def leave_when_empty(yes_no)
  boolean :leavewhenempty => yes_no
end

- (Object) maximum_length(number)



150
151
152
# File 'lib/adhearsion/asterisk/config_generator/queues.rb', line 150

def maximum_length(number)
  int :maxlen => number
end

- (Object) member(driver)



238
239
240
# File 'lib/adhearsion/asterisk/config_generator/queues.rb', line 238

def member(driver)
  members << (driver.kind_of?(String) && driver =~ %r'/' ? driver : "Agent/#{driver}")
end

- (Object) monitor_format(symbol)



173
174
175
# File 'lib/adhearsion/asterisk/config_generator/queues.rb', line 173

def monitor_format(symbol)
  one_of [:wav, :gsm, :wav49], 'monitor-format' => symbol
end

- (Object) monitor_type(symbol)



177
178
179
180
# File 'lib/adhearsion/asterisk/config_generator/queues.rb', line 177

def monitor_type(symbol)
  criteria = {:monitor => "Monitor", :mix_monitor => "MixMonitor"}
  one_of_and_translate criteria, 'monitor-type' => symbol
end

- (Object) music_class(moh_identifier)



99
100
101
# File 'lib/adhearsion/asterisk/config_generator/queues.rb', line 99

def music_class(moh_identifier)
  string :musicclass => moh_identifier
end

- (Object) periodically_announce(sound_file, options = {})



158
159
160
161
162
163
# File 'lib/adhearsion/asterisk/config_generator/queues.rb', line 158

def periodically_announce(sound_file, options={})
  frequency = options.delete(:every) || 1.minute

  string 'periodic-announce' => sound_file
  int 'periodic-announce-frequency' => frequency
end

- (Object) play_on_connect(sound_file)



103
104
105
# File 'lib/adhearsion/asterisk/config_generator/queues.rb', line 103

def play_on_connect(sound_file)
  string :announce => sound_file
end

- (Object) queue_status_announce_frequency(seconds)



154
155
156
# File 'lib/adhearsion/asterisk/config_generator/queues.rb', line 154

def queue_status_announce_frequency(seconds)
  int "announce-frequency" => seconds
end

- (Object) report_hold_time(yes_no)



192
193
194
# File 'lib/adhearsion/asterisk/config_generator/queues.rb', line 192

def report_hold_time(yes_no)
  boolean :reportholdtime => yes_no
end

- (Object) retry_after_waiting(seconds)

Ex: retry_after_waiting 5.seconds



131
132
133
# File 'lib/adhearsion/asterisk/config_generator/queues.rb', line 131

def retry_after_waiting(seconds)
  int :retry => seconds
end

- (Object) ring_in_use(yes_no)



196
197
198
# File 'lib/adhearsion/asterisk/config_generator/queues.rb', line 196

def ring_in_use(yes_no)
  boolean :ringinuse => yes_no
end

- (Object) ring_timeout(seconds)

Ex: ring_timeout 15.seconds



126
127
128
# File 'lib/adhearsion/asterisk/config_generator/queues.rb', line 126

def ring_timeout(seconds)
  int :timeout => seconds
end

- (Object) service_level(seconds)



111
112
113
# File 'lib/adhearsion/asterisk/config_generator/queues.rb', line 111

def service_level(seconds)
  int :servicelevel => seconds
end

- (Object) sound_files(hash_of_files)

Give a Hash argument here to override the default sound files for this queue.

Usage:

queue.sound_files :you_are_next          => 'queue-youarenext',
                  :there_are             => 'queue-thereare',
                  :calls_waiting         => 'queue-callswaiting',
                  :hold_time             => 'queue-holdtime',
                  :minutes               => 'queue-minutes',
                  :seconds               => 'queue-seconds',
                  :thank_you             => 'queue-thankyou',
                  :less_than             => 'queue-less-than',
                  :report_hold           => 'queue-reporthold',
                  :periodic_announcement => 'queue-periodic-announce'

Note: the Hash values are the defaults. You only need to specify the ones you wish to override.



227
228
229
230
231
232
233
234
235
236
# File 'lib/adhearsion/asterisk/config_generator/queues.rb', line 227

def sound_files(hash_of_files)
  hash_of_files.each_pair do |key, value|
    unless SOUND_FILE_SYMBOL_INTERPRETATIONS.has_key? key
      message = "Unrecogized sound file identifier #{key.inspect}. " +
            "Supported: " + SOUND_FILE_SYMBOL_INTERPRETATIONS.keys.map(&:inspect).to_sentence
      raise ArgumentError, message
    end
    @sound_files[SOUND_FILE_SYMBOL_INTERPRETATIONS[key]] = value
  end
end

- (Object) strategy(symbol)



107
108
109
# File 'lib/adhearsion/asterisk/config_generator/queues.rb', line 107

def strategy(symbol)
  one_of SUPPORTED_RING_STRATEGIES, :strategy => symbol
end

- (Object) timeout_restart(yes_no)



206
207
208
# File 'lib/adhearsion/asterisk/config_generator/queues.rb', line 206

def timeout_restart(yes_no)
  boolean :timeoutrestart => yes_no
end

- (Object) to_s



93
94
95
96
97
# File 'lib/adhearsion/asterisk/config_generator/queues.rb', line 93

def to_s
  "[#{name}]\n" +
  properties.merge(@sound_files).map { |key, value| "#{key}=#{value}" }.sort.join("\n") + "\n\n" +
  members.map { |member| "member => #{member}" }.join("\n")
end

- (Object) weight(number)

THIS IS UNSUPPORTED



136
137
138
# File 'lib/adhearsion/asterisk/config_generator/queues.rb', line 136

def weight(number)
  int :weight => number
end

- (Object) wrapup_time(seconds)

Ex: wrapup_time 1.minute



141
142
143
# File 'lib/adhearsion/asterisk/config_generator/queues.rb', line 141

def wrapup_time(seconds)
  int :wrapuptime => seconds
end