class SayWhen::YearsCronValue
Public Class Methods
new(exp)
click to toggle source
Calls superclass method
SayWhen::CronValue::new
# File lib/say_when/cron_expression.rb, line 535 def initialize(exp) super(:year, 1970, (Date.today.year + 100), exp) end
Public Instance Methods
last(date)
click to toggle source
# File lib/say_when/cron_expression.rb, line 548 def last(date) last_year = values.reverse.detect { |v| v < date.year } if last_year.nil? return nil else date.change(year: last_year, month: 12, day: 31, hour: 23, min: 59, sec: 59) end end
next(date)
click to toggle source
# File lib/say_when/cron_expression.rb, line 539 def next(date) next_year = values.detect { |v| v > date.year } if next_year.nil? return nil else date.change(year: next_year, month: 1, day: 1, hour: 0) end end