Class: TaskBag::Worker
- Inherits:
-
Object
- Object
- TaskBag::Worker
- Defined in:
- lib/taskbag/worker.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(bag) ⇒ Worker
constructor
A new instance of Worker.
- #start ⇒ Object
Constructor Details
#initialize(bag) ⇒ Worker
Returns a new instance of Worker.
3 4 5 |
# File 'lib/taskbag/worker.rb', line 3 def initialize(bag) @bag = bag end |
Class Method Details
.start(bag) ⇒ Object
7 8 9 |
# File 'lib/taskbag/worker.rb', line 7 def self.start(bag) Worker.new(bag).start end |
Instance Method Details
#start ⇒ Object
11 12 13 14 15 16 17 18 |
# File 'lib/taskbag/worker.rb', line 11 def start until @bag.closed? job = @bag.next (sleep(1) and next) if job.nil? job.run end end |