Module: Asyncron::Schedule

Extended by:
Schedule
Included in:
Schedule
Defined in:
lib/asyncron/schedule.rb

Instance Method Summary collapse

Instance Method Details

#map(time = nil) ⇒ Object



7
8
9
10
# File 'lib/asyncron/schedule.rb', line 7

def map(time = nil)
  time = Time.now + 60 if time.nil?
  %w(min hour day month wday year).map { |m| time.send(m) }
end

#next(expr) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/asyncron/schedule.rb', line 12

def next(expr)
  cron = Cron.parse(expr)
  current = map
  year(cron, current) do
    month(cron, current) do
      day(cron, current) do
        hour(cron, current) do
          min(cron, current) do
            Time.new(current[5], current[3], current[2], current[1],
              current[0])
          end
        end
      end
    end
  end
end