Class Rufus::CronLine
In: lib/rufus/sc/cronline.rb
Parent: Object

A ‘cron line’ is a line in the sense of a crontab (man 5 crontab) file line.

Methods

matches?   new   next_time   to_array  

Constants

WDS = %w[ sun mon tue wed thu fri sat ]

Attributes

days  [R] 
hours  [R] 
minutes  [R] 
months  [R] 
original  [R]  The string used for creating this cronline instance.
seconds  [R] 
weekdays  [R] 

Public Class methods

Public Instance methods

Returns true if the given time matches this cron line.

Returns the next time that this cron line is supposed to ‘fire‘

This is raw, 3 secs to iterate over 1 year on my macbook :( brutal. (Well, I was wrong, takes 0.001 sec on 1.8.7 and 1.9.1)

This method accepts an optional Time parameter. It‘s the starting point for the ‘search’. By default, it‘s Time.now

Note that the time instance returned will be in the same time zone that the given start point Time (thus a result in the local time zone will be passed if no start time is specified (search start time set to Time.now))

  >> Rufus::CronLine.new('30 7 * * *').next_time( Time.mktime(2008,10,24,7,29) )
  => Fri Oct 24 07:30:00 -0500 2008

  >> Rufus::CronLine.new('30 7 * * *').next_time( Time.utc(2008,10,24,7,29) )
  => Fri Oct 24 07:30:00 UTC 2008

  >> Rufus::CronLine.new('30 7 * * *').next_time( Time.utc(2008,10,24,7,29)  ).localtime
  => Fri Oct 24 02:30:00 -0500 2008

(Thanks to K Liu for the note and the examples)

Returns an array of 6 arrays (seconds, minutes, hours, days, months, weekdays). This method is used by the cronline unit tests.

[Validate]