class Rufus::Scheduler::CronLine
def brute_frequency
for a discussion about this method.
See https://github.com/jmettraux/rufus-scheduler/issues/89
One obvious improvement would be to cache the result once computed...
smarter/faster.
Since it's a rarely used method, I haven't taken the time to make it
based cronline...
Of course, this method can get VERY slow if you call on it a second-
of a whole year and keeps the shortest.
sunday). This method takes no chance and runs next_time for the span
(the shortest delta is the one between the second sunday and the third
Consider "* * * * sun#2,sun#3", the computed frequency is 1 week
five minutes. Why does this method look at a whole year of #next_time ?
For a simple cronline like "*/5 * * * *", obviously the frequency is
.
schedule described by this cronline.
Returns the shortest delta between two potential occurences of the
def brute_frequency delta = 366 * DAY_S t0 = previous_time(Time.local(2000, 1, 1)) loop do break if delta <= 1 break if delta <= 60 && @seconds && @seconds.size == 1 t1 = next_time(t0) d = t1 - t0 delta = d if d < delta break if @months == nil && t1.month == 2 break if t1.year >= 2001 t0 = t1 end delta end