Class: Wristwatch::Dispatch
- Inherits:
-
Object
- Object
- Wristwatch::Dispatch
- Defined in:
- lib/wristwatch/dispatch.rb
Instance Method Summary collapse
- #execute ⇒ Object
-
#initialize(tasks, schedule) ⇒ Dispatch
constructor
A new instance of Dispatch.
- #list ⇒ Object
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
#execute ⇒ Object
13 14 15 |
# File 'lib/wristwatch/dispatch.rb', line 13 def execute list.each(&:call) end |
#list ⇒ Object
9 10 11 |
# File 'lib/wristwatch/dispatch.rb', line 9 def list @schedule.inject([]) {|list, interval| list += @tasks[interval] if @tasks[interval]; list } end |