Class: Crono::Scheduler

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

Overview

Scheduler is a container for job list and queue

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeScheduler

Returns a new instance of Scheduler.



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

def initialize
  self.jobs = []
end

Instance Attribute Details

#jobsObject

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_jobsObject



15
16
17
# File 'lib/crono/scheduler.rb', line 15

def next_jobs
  jobs.group_by(&:next).sort_by {|time,_| time }.first
end