Class: ElectricSlide::AgentStrategy::LongestIdle
- Inherits:
-
Object
- Object
- ElectricSlide::AgentStrategy::LongestIdle
- Defined in:
- lib/electric_slide/agent_strategy/longest_idle.rb
Instance Method Summary collapse
- #<<(agent) ⇒ Object
-
#agent_available? ⇒ Boolean
Checks whether an agent is available to take a call.
-
#available_agent_summary ⇒ Hash
Returns a count of the number of available agents This strategy only returns the count of agents available with :total.
-
#checkout_agent ⇒ Agent
Assigns the first available agent, marking the agent :on_call.
- #delete(agent) ⇒ Object
-
#initialize ⇒ LongestIdle
constructor
A new instance of LongestIdle.
Constructor Details
#initialize ⇒ LongestIdle
Returns a new instance of LongestIdle.
6 7 8 |
# File 'lib/electric_slide/agent_strategy/longest_idle.rb', line 6 def initialize @free_agents = [] # Needed to keep track of waiting order end |
Instance Method Details
#<<(agent) ⇒ Object
29 30 31 |
# File 'lib/electric_slide/agent_strategy/longest_idle.rb', line 29 def <<(agent) @free_agents << agent unless @free_agents.include?(agent) end |
#agent_available? ⇒ Boolean
Checks whether an agent is available to take a call
12 13 14 |
# File 'lib/electric_slide/agent_strategy/longest_idle.rb', line 12 def agent_available? @free_agents.count > 0 end |
#available_agent_summary ⇒ Hash
Returns a count of the number of available agents This strategy only returns the count of agents available with :total
19 20 21 |
# File 'lib/electric_slide/agent_strategy/longest_idle.rb', line 19 def available_agent_summary { total: @free_agents.count } end |
#checkout_agent ⇒ Agent
Assigns the first available agent, marking the agent :on_call
25 26 27 |
# File 'lib/electric_slide/agent_strategy/longest_idle.rb', line 25 def checkout_agent @free_agents.shift end |
#delete(agent) ⇒ Object
33 34 35 |
# File 'lib/electric_slide/agent_strategy/longest_idle.rb', line 33 def delete(agent) @free_agents.delete(agent) end |