Method: LucidWorks::Datasource::Schedule#next_start
- Defined in:
- lib/lucid_works/datasource/schedule.rb
#next_start ⇒ Object
predict when action will occur next if active at that time
60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/lucid_works/datasource/schedule.rb', line 60 def next_start return start_time if (now = Time.now) <= start_time time_since_start = now - start_time last_interval_num = (time_since_start / period).to_i next_interval_num = if (time_since_start % period) == 0 # this is sort of a stupid condition b/c time precision is millisecond or less # for human purposes we wouldn't care if the result were as though the call # happened a millisecond later. But whatever. last_interval_num # the next interval *is* the last interval if it is exactly now else last_interval_num + 1 end start_time + period * next_interval_num end |