Class: Crono::Scheduler
- Inherits:
-
Object
- Object
- Crono::Scheduler
- Defined in:
- lib/crono/scheduler.rb
Overview
Scheduler is a container for job list and queue
Instance Attribute Summary collapse
-
#jobs ⇒ Object
Returns the value of attribute jobs.
Instance Method Summary collapse
- #add_job(job) ⇒ Object
-
#initialize ⇒ Scheduler
constructor
A new instance of Scheduler.
- #next_jobs ⇒ Object
Constructor Details
#initialize ⇒ Scheduler
Returns a new instance of Scheduler.
6 7 8 |
# File 'lib/crono/scheduler.rb', line 6 def initialize self.jobs = [] end |
Instance Attribute Details
#jobs ⇒ Object
Returns the value of attribute jobs.
4 5 6 |
# File 'lib/crono/scheduler.rb', line 4 def jobs @jobs end |
Instance Method Details
#add_job(job) ⇒ Object
10 11 12 13 |
# File 'lib/crono/scheduler.rb', line 10 def add_job(job) job.load jobs << job end |
#next_jobs ⇒ Object
15 16 17 |
# File 'lib/crono/scheduler.rb', line 15 def next_jobs jobs.group_by(&:next).sort_by {|time,_| time }.first end |