Class: Wakame::Scheduler

Inherits:
Object
  • Object
show all
Defined in:
lib/wakame/scheduler.rb

Defined Under Namespace

Classes: LoopSequence, PerDaySequence, PerHourSequence, PerMinuteSequence, PerWeekSequence, Sequence, SequenceTimer, TimedSequence, UnitTimeSequence

Instance Method Summary collapse

Constructor Details

#initializeScheduler

Returns a new instance of Scheduler.



6
7
8
# File 'lib/wakame/scheduler.rb', line 6

def initialize
  @channels = {}
end

Instance Method Details

#add_sequence(key, seq) ⇒ Object



10
11
12
# File 'lib/wakame/scheduler.rb', line 10

def add_sequence(key, seq)
  @channels[key]=seq
end

#next_event(time) ⇒ Object



15
16
17
18
19
20
21
22
# File 'lib/wakame/scheduler.rb', line 15

def next_event(time)
  n = @channels.collect { |k, seq|
    seq.next_event(time)
  }
  n.compact!
  n = n.sort {|a,b| a[0] <=> b[0] }
  n.first
end