class Cyclical::DailyRule
holds daily rule configuration
Public Instance Methods
aligned?(time, base)
click to toggle source
# File lib/cyclical/rules/daily_rule.rb, line 7 def aligned?(time, base) return false unless (base.to_date - time.to_date) % @interval == 0 return false unless [time.hour, time.min, time.sec] == [base.hour, base.min, base.sec] true end
step()
click to toggle source
# File lib/cyclical/rules/daily_rule.rb, line 14 def step @interval.days end
Protected Instance Methods
align(time, base)
click to toggle source
# File lib/cyclical/rules/daily_rule.rb, line 42 def align(time, base) # compensate crossing DST barrier (oh my...) offset = time.beginning_of_day.utc_offset time = time.beginning_of_day + base.hour.hours + base.min.minutes + base.sec.seconds time += (offset - time.utc_offset) end
potential_next(current, base)
click to toggle source
Calls superclass method
Cyclical::Rule#potential_next
# File lib/cyclical/rules/daily_rule.rb, line 20 def potential_next(current, base) candidate = super(current, base) rem = (base.to_date - candidate.to_date) % @interval return candidate if rem == 0 rem += @interval if rem < 0 candidate.beginning_of_day + rem.days end
potential_previous(current, base)
click to toggle source
Calls superclass method
Cyclical::Rule#potential_previous
# File lib/cyclical/rules/daily_rule.rb, line 31 def potential_previous(current, base) candidate = super(current, base) rem = (base.to_date - candidate.to_date) % @interval return candidate if rem == 0 rem += @interval if rem < 0 candidate.beginning_of_day + (rem - @interval).days end