Class: Fugit::Cron::TimeCursor
- Inherits:
-
Object
- Object
- Fugit::Cron::TimeCursor
- Defined in:
- lib/fugit/cron.rb
Instance Method Summary collapse
- #dec(i) ⇒ Object
- #dec_day ⇒ Object
- #dec_hour ⇒ Object
- #dec_min ⇒ Object
- #dec_month ⇒ Object
- #dec_sec ⇒ Object
- #inc(i) ⇒ Object
- #inc_day ⇒ Object
- #inc_hour ⇒ Object
- #inc_min ⇒ Object
- #inc_month ⇒ Object
- #inc_sec ⇒ Object
-
#initialize(cron, t) ⇒ TimeCursor
constructor
A new instance of TimeCursor.
- #time ⇒ Object
- #to_i ⇒ Object
Constructor Details
#initialize(cron, t) ⇒ TimeCursor
Returns a new instance of TimeCursor.
68 69 70 71 72 |
# File 'lib/fugit/cron.rb', line 68 def initialize(cron, t) @cron = cron @t = t.is_a?(TimeCursor) ? t.time : t @t.seconds = @t.seconds.to_i end |
Instance Method Details
#dec(i) ⇒ Object
84 |
# File 'lib/fugit/cron.rb', line 84 def dec(i); inc(-i); end |
#dec_day ⇒ Object
121 122 123 |
# File 'lib/fugit/cron.rb', line 121 def dec_day dec(@t.hour * 3600 + @t.min * 60 + @t.sec + 1) end |
#dec_hour ⇒ Object
124 125 126 |
# File 'lib/fugit/cron.rb', line 124 def dec_hour dec(@t.min * 60 + @t.sec + 1) end |
#dec_min ⇒ Object
127 128 129 |
# File 'lib/fugit/cron.rb', line 127 def dec_min dec(@t.sec + 1) end |
#dec_month ⇒ Object
112 113 114 115 116 117 118 119 |
# File 'lib/fugit/cron.rb', line 112 def dec_month #dec(@t.day * 24 * 3600 + @t.hour * 3600 + @t.min * 60 + @t.sec + 1) # # gh-18, so that '0 9 29 feb *' doesn't get skipped (over and over) # dec(@t.day * 24 * 3600 + 1) end |
#dec_sec ⇒ Object
131 132 133 134 135 136 |
# File 'lib/fugit/cron.rb', line 131 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) ⇒ Object
80 81 82 83 |
# File 'lib/fugit/cron.rb', line 80 def inc(i) @t = @t + i self end |
#inc_day ⇒ Object
94 95 96 |
# File 'lib/fugit/cron.rb', line 94 def inc_day inc((24 - @t.hour) * 3600 - @t.min * 60 - @t.sec) end |
#inc_hour ⇒ Object
97 98 99 |
# File 'lib/fugit/cron.rb', line 97 def inc_hour inc((60 - @t.min) * 60 - @t.sec) end |
#inc_min ⇒ Object
100 101 102 |
# File 'lib/fugit/cron.rb', line 100 def inc_min inc(60 - @t.sec) end |
#inc_month ⇒ Object
86 87 88 89 90 91 92 |
# File 'lib/fugit/cron.rb', line 86 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 ⇒ Object
104 105 106 107 108 109 110 |
# File 'lib/fugit/cron.rb', line 104 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 ⇒ Object
74 |
# File 'lib/fugit/cron.rb', line 74 def time; @t; end |
#to_i ⇒ Object
75 |
# File 'lib/fugit/cron.rb', line 75 def to_i; @t.to_i; end |