Class: Wristwatch::Dispatch

Inherits:
Object
  • Object
show all
Defined in:
lib/wristwatch/dispatch.rb

Instance Method Summary collapse

Constructor Details

#initialize(tasks, schedule) ⇒ Dispatch

Returns a new instance of Dispatch.



4
5
6
7
# File 'lib/wristwatch/dispatch.rb', line 4

def initialize(tasks, schedule)
  @tasks = tasks
  @schedule = schedule
end

Instance Method Details

#executeObject



13
14
15
# File 'lib/wristwatch/dispatch.rb', line 13

def execute
  list.each(&:call)
end

#listObject



9
10
11
# File 'lib/wristwatch/dispatch.rb', line 9

def list
  @schedule.inject([]) {|list, interval| list += @tasks[interval] if @tasks[interval]; list }
end