Class: Adhearsion::Asterisk::QueueProxy::QueueAgentsListProxy
- Inherits:
-
Object
- Object
- Adhearsion::Asterisk::QueueProxy::QueueAgentsListProxy
- Includes:
- Enumerable
- Defined in:
- lib/adhearsion/asterisk/queue_proxy/queue_agents_list_proxy.rb
Instance Attribute Summary (collapse)
-
- (Object) agents
readonly
Returns the value of attribute agents.
-
- (Object) proxy
readonly
Returns the value of attribute proxy.
Instance Method Summary (collapse)
- - (Boolean) cached?
- - (Object) count (also: #size, #length)
- - (Object) each(&block)
- - (Object) first
-
- (QueueAgentsListProxy) initialize(proxy, cached = false)
constructor
A new instance of QueueAgentsListProxy.
- - (Object) last
-
- (Object) login!(*args)
Logs a pre-defined agent into this queue and waits for calls.
-
- (Object) logout!
Removes the current channel from this queue.
-
- (Object) new(*args)
:name value will be viewable in the queue_log :penalty is the penalty assigned to this agent for answering calls on this queue.
- - (Object) to_a
Constructor Details
- (QueueAgentsListProxy) initialize(proxy, cached = false)
A new instance of QueueAgentsListProxy
9 10 11 12 |
# File 'lib/adhearsion/asterisk/queue_proxy/queue_agents_list_proxy.rb', line 9 def initialize(proxy, cached = false) @proxy = proxy @cached = cached end |
Instance Attribute Details
- (Object) agents (readonly)
Returns the value of attribute agents
7 8 9 |
# File 'lib/adhearsion/asterisk/queue_proxy/queue_agents_list_proxy.rb', line 7 def agents @agents end |
- (Object) proxy (readonly)
Returns the value of attribute proxy
7 8 9 |
# File 'lib/adhearsion/asterisk/queue_proxy/queue_agents_list_proxy.rb', line 7 def proxy @proxy end |
Instance Method Details
- (Boolean) cached?
103 104 105 |
# File 'lib/adhearsion/asterisk/queue_proxy/queue_agents_list_proxy.rb', line 103 def cached? @cached end |
- (Object) count Also known as: size, length
14 15 16 17 18 19 20 |
# File 'lib/adhearsion/asterisk/queue_proxy/queue_agents_list_proxy.rb', line 14 def count if cached? && @cached_count @cached_count else @cached_count = proxy.environment.get_variable("QUEUE_MEMBER_COUNT(#{proxy.name})").to_i end end |
- (Object) each(&block)
88 89 90 91 |
# File 'lib/adhearsion/asterisk/queue_proxy/queue_agents_list_proxy.rb', line 88 def each(&block) check_agent_cache! agents.each &block end |
- (Object) first
93 94 95 96 |
# File 'lib/adhearsion/asterisk/queue_proxy/queue_agents_list_proxy.rb', line 93 def first check_agent_cache! agents.first end |
- (Object) last
98 99 100 101 |
# File 'lib/adhearsion/asterisk/queue_proxy/queue_agents_list_proxy.rb', line 98 def last check_agent_cache! agents.last end |
- (Object) login!(*args)
Logs a pre-defined agent into this queue and waits for calls. Pass in :silent => true to stop the message which says "Agent logged in".
62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/adhearsion/asterisk/queue_proxy/queue_agents_list_proxy.rb', line 62 def login!(*args) = args.last.kind_of?(Hash) ? args.pop : {} silent = .delete(:silent).equal?(false) ? '' : 's' id = args.shift id &&= AgentProxy.id_from_agent_channel(id) raise ArgumentError, "Unrecognized Hash options to #login: #{.inspect}" if .any? raise ArgumentError, "Unrecognized argument to #login: #{args.inspect}" if args.any? proxy.environment.execute 'AgentLogin', id, silent end |
- (Object) logout!
Removes the current channel from this queue
75 76 77 78 79 80 81 82 83 84 85 86 |
# File 'lib/adhearsion/asterisk/queue_proxy/queue_agents_list_proxy.rb', line 75 def logout! # TODO: DRY this up. Repeated in the AgentProxy... proxy.environment.execute 'RemoveQueueMember', proxy.name case proxy.environment.get_variable("RQMSTATUS") when "REMOVED" then true when "NOTINQUEUE" then false when "NOSUCHQUEUE" raise QueueDoesNotExistError.new(proxy.name) else raise "Unrecognized RQMSTATUS variable!" end end |
- (Object) new(*args)
:name value will be viewable in the queue_log :penalty is the penalty assigned to this agent for answering calls on this queue
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/adhearsion/asterisk/queue_proxy/queue_agents_list_proxy.rb', line 27 def new(*args) = args.last.kind_of?(Hash) ? args.pop : {} interface = args.shift raise ArgumentError, "You must specify an interface to add." if interface.nil? raise ArgumentError, "You may only supply an interface and a Hash argument!" if args.any? penalty = .delete(:penalty) || '' name = .delete(:name) || '' state_interface = .delete(:state_interface) || '' raise ArgumentError, "Unrecognized argument(s): #{.inspect}" if .any? proxy.environment.execute "AddQueueMember", proxy.name, interface, penalty, '', name, state_interface added = case proxy.environment.get_variable("AQMSTATUS") when "ADDED" then true when "MEMBERALREADY" then false when "NOSUCHQUEUE" then raise QueueDoesNotExistError.new(proxy.name) else raise "UNRECOGNIZED AQMSTATUS VALUE!" end if added check_agent_cache! AgentProxy.new(interface, proxy).tap do |agent_proxy| @agents << agent_proxy end else false end end |
- (Object) to_a
107 108 109 110 |
# File 'lib/adhearsion/asterisk/queue_proxy/queue_agents_list_proxy.rb', line 107 def to_a check_agent_cache! @agents end |