class CronSpec::DowFactory

Factory for constructing Day of week values from a cron specification.

Constants

DayOfWeekExpression

A pipe-delimited expression for the days of the week

DayOfWeekLowerLimit

The lower limit for the value of a day of the week (0-Sunday)

DayOfWeekRangePattern

Regular expression that matches a range of days of the week

DayOfWeekSingleValuePattern

A regular expression that matches a single day of the week.

DayOfWeekUpperLimit

The upper limit for the value of a day of the week (6-Saturday)

DaysOfWeek

The supported names for the days of the week

NamedDayOfWeekPattern

Regular expression that matches only a named day of the week.

Public Class Methods

new() click to toggle source

Constructs a new DowFactory object.

Calls superclass method CronSpec::CronSpecificationFactory::new
# File lib/cron-spec/dow_factory.rb, line 31
def initialize
  super
  @lower_limit = DayOfWeekLowerLimit
  @upper_limit = DayOfWeekUpperLimit
  @single_value_pattern = DayOfWeekSingleValuePattern
  @range_pattern = DayOfWeekRangePattern
end

Private Instance Methods

convert_value(value) click to toggle source
# File lib/cron-spec/dow_factory.rb, line 41
def convert_value(value)
  dow = (value =~ NamedDayOfWeekPattern) ? DaysOfWeek.index(value) : value.to_i
  # Sunday can be specified as index 7
  (dow == 7) ? 0 : dow
end