class Fugit::Cron::TimeCursor
Public Class Methods
new(cron, t)
click to toggle source
# File lib/fugit/cron.rb, line 70 def initialize(cron, t) @cron = cron @t = t.is_a?(TimeCursor) ? t.time : t @t.seconds = @t.seconds.to_i end
Public Instance Methods
dec(i)
click to toggle source
# File lib/fugit/cron.rb, line 85 def dec(i); inc(-i); end
dec_day()
click to toggle source
# File lib/fugit/cron.rb, line 134 def dec_day dec(@t.hour * 3600 + @t.min * 60 + @t.sec + 1) end
dec_hour()
click to toggle source
# File lib/fugit/cron.rb, line 137 def dec_hour dec(@t.min * 60 + @t.sec + 1) end
dec_min()
click to toggle source
# File lib/fugit/cron.rb, line 140 def dec_min dec(@t.sec + 1) end
dec_month()
click to toggle source
# File lib/fugit/cron.rb, line 130 def dec_month dec((@t.day - 1) * DAY_S + @t.hour * 3600 + @t.min * 60 + @t.sec + 1) end
dec_sec()
click to toggle source
# File lib/fugit/cron.rb, line 144 def dec_sec target = @cron.seconds.reverse.find { |s| s < @t.sec } || @cron.seconds.last inc(target - @t.sec - (@t.sec > target ? 0 : 60)) end
inc(i)
click to toggle source
# File lib/fugit/cron.rb, line 84 def inc(i); @t = @t + i; self; end
inc_day()
click to toggle source
# File lib/fugit/cron.rb, line 98 def inc_day inc((24 - @t.hour) * 3600 - @t.min * 60 - @t.sec) return if @t.hour == 0 if @t.hour < 12 begin @t = ::EtOrbi.make(@t.year, @t.month, @t.day, @t.zone) rescue ::TZInfo::PeriodNotFound inc((24 - @t.hour) * 3600) end else inc((24 - @t.hour) * 3600) end end
inc_hour()
click to toggle source
# File lib/fugit/cron.rb, line 115 def inc_hour inc((60 - @t.min) * 60 - @t.sec) end
inc_min()
click to toggle source
# File lib/fugit/cron.rb, line 118 def inc_min inc(60 - @t.sec) end
inc_month()
click to toggle source
# File lib/fugit/cron.rb, line 87 def inc_month y = @t.year m = @t.month + 1 if m == 13; m = 1; y += 1; end @t = ::EtOrbi.make(y, m, @t.zone) self end
inc_sec()
click to toggle source
# File lib/fugit/cron.rb, line 122 def inc_sec if sec = @cron.seconds.find { |s| s > @t.sec } inc(sec - @t.sec) else inc(60 - @t.sec + @cron.seconds.first) end end
time()
click to toggle source
# File lib/fugit/cron.rb, line 76 def time; @t; end
to_i()
click to toggle source
# File lib/fugit/cron.rb, line 79 def to_i; @t.to_i; end
to_t()
click to toggle source
# File lib/fugit/cron.rb, line 77 def to_t; @t; end