Class: PerfectSched::CronCalc

Inherits:
Object
  • Object
show all
Defined in:
lib/perfectsched/croncalc.rb

Instance Method Summary collapse

Constructor Details

#initializeCronCalc

Returns a new instance of CronCalc.



6
7
8
9
# File 'lib/perfectsched/croncalc.rb', line 6

def initialize
  require 'cron-spec'
  # TODO optimize
end

Instance Method Details

#next_time(cron, time) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
# File 'lib/perfectsched/croncalc.rb', line 11

def next_time(cron, time)
  t = Time.at(time)
  tab = CronSpec::CronSpecification.new(cron)
  while true
    t += 60
    if tab.is_specification_in_effect?(t)
      return t.to_i
    end
    # FIXME break
  end
end