Class: MicroManager::Schedule
- Inherits:
-
Object
- Object
- MicroManager::Schedule
- Defined in:
- lib/micro_manager/schedule.rb
Instance Method Summary collapse
- #add_task(description:, due:) ⇒ Object
-
#initialize(tasks: []) ⇒ Schedule
constructor
A new instance of Schedule.
- #outstanding_tasks ⇒ Object
- #tasks_completed(on:) ⇒ Object
Constructor Details
#initialize(tasks: []) ⇒ Schedule
Returns a new instance of Schedule.
5 6 7 |
# File 'lib/micro_manager/schedule.rb', line 5 def initialize(tasks: []) @tasks = tasks end |
Instance Method Details
#add_task(description:, due:) ⇒ Object
9 10 11 |
# File 'lib/micro_manager/schedule.rb', line 9 def add_task(description:, due:) tasks << Task.new(description: description, due: due) end |
#outstanding_tasks ⇒ Object
13 14 15 16 17 |
# File 'lib/micro_manager/schedule.rb', line 13 def outstanding_tasks tasks .reject(&:completed?) .sort_by(&:due) end |
#tasks_completed(on:) ⇒ Object
19 20 21 |
# File 'lib/micro_manager/schedule.rb', line 19 def tasks_completed(on:) tasks.select { |task| task.completed? && task.completed_on == on } end |