Class: Cronline::CronYears

Inherits:
CronField show all
Defined in:
lib/cronline/cron_years.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from CronField

#range, #test?, wildcard

Constructor Details

#initialize(cron_expression) ⇒ CronYears

Returns a new instance of CronYears.



12
13
14
15
16
17
18
19
# File 'lib/cronline/cron_years.rb', line 12

def initialize(cron_expression)
  expression = cron_expression.split(' ')[6]
  if expression.nil?
    super(CronField.wildcard, CronYears.absolute_min_year , CronYears.absolute_max_year)
  else
    super(expression, CronYears.absolute_min_year , CronYears.absolute_max_year)
  end
end

Class Method Details

.absolute_max_yearObject



8
9
10
# File 'lib/cronline/cron_years.rb', line 8

def self.absolute_max_year
  2099
end

.absolute_min_yearObject



4
5
6
# File 'lib/cronline/cron_years.rb', line 4

def self.absolute_min_year
  1970
end

Instance Method Details

#time_field(time) ⇒ Object



21
22
23
# File 'lib/cronline/cron_years.rb', line 21

def time_field(time)
  time.year
end