Class: Scheduler
- Inherits:
-
Object
show all
- Defined in:
- lib/delve/scheduler/scheduler.rb
Instance Method Summary
collapse
Constructor Details
#initialize(event_queue) ⇒ Scheduler
Returns a new instance of Scheduler.
3
4
5
6
7
|
# File 'lib/delve/scheduler/scheduler.rb', line 3
def initialize(event_queue)
@queue = event_queue
@current = nil
@repeat = Array.new
end
|
Instance Method Details
#add(item, repeat = false) ⇒ Object
33
34
35
|
# File 'lib/delve/scheduler/scheduler.rb', line 33
def add(item, repeat=false)
@repeat << item if repeat
end
|
#clear ⇒ Object
27
28
29
30
31
|
# File 'lib/delve/scheduler/scheduler.rb', line 27
def clear
@queue.clear
@current = nil
@repeat = Array.new
end
|
#next ⇒ Object
13
14
15
16
|
# File 'lib/delve/scheduler/scheduler.rb', line 13
def next
@current = @queue.get
@current
end
|
#remove(item) ⇒ Object
18
19
20
21
22
23
24
25
|
# File 'lib/delve/scheduler/scheduler.rb', line 18
def remove(item)
result = @queue.remove item
index = @repeat.index item
@events.delete_at index if index
result
end
|
#time ⇒ Object
9
10
11
|
# File 'lib/delve/scheduler/scheduler.rb', line 9
def time
@queue.time
end
|