class Coordinator::Queue

Attributes

skill[R]

Public Class Methods

new(skill, capacity=nil, &block) click to toggle source
Calls superclass method
# File lib/coordinator/queue.rb, line 5
def initialize(skill, capacity=nil, &block)
  @skill = skill
  @custom_block = block if block_given?

  super(skill)

  self.capacity = capacity if capacity
end

Public Instance Methods

details() click to toggle source
# File lib/coordinator/queue.rb, line 29
def details
  {
    "name" => @skill,
    "full" => full?,
    "capacity" => capacity,
    "count" => length,
    "items" => items
  }
end
eligible?(task, skills) click to toggle source
# File lib/coordinator/queue.rb, line 21
def eligible?(task, skills)
  if @custom_block
    self.instance_exec(task, skills, &@custom_block)
  else
    skills.include?(@skill)
  end
end
next_task(skills) click to toggle source
# File lib/coordinator/queue.rb, line 14
def next_task(skills)
  task = peek
  return nil unless task && eligible?(task, skills)
  return task if remove(task)
  next_task(skills)
end