class CronInfo::DayOfWeekParser

Public Instance Methods

day_of_week_mappings() click to toggle source
# File lib/cron_info/day_of_week_parser.rb, line 3
def day_of_week_mappings
  {
    "mon" => 1,
    "tue" => 2,
    "wed" => 3,
    "thu" => 4,
    "fri" => 5,
    "sat" => 6,
    "sun" => 7
  }
end
label() click to toggle source
# File lib/cron_info/day_of_week_parser.rb, line 38
def label
  "day of week"
end
max_value() click to toggle source
# File lib/cron_info/day_of_week_parser.rb, line 34
def max_value
  7
end
min_value() click to toggle source
# File lib/cron_info/day_of_week_parser.rb, line 30
def min_value
  1
end
parse_word(cron_string) click to toggle source
# File lib/cron_info/day_of_week_parser.rb, line 23
def parse_word(cron_string)
  if day_of_week_mappings[cron_string.downcase] == nil
    raise "Invalid day of week argument #{cron_string}"
  end
  [day_of_week_mappings[cron_string.downcase]]
end
parse_word_range(cron_string) click to toggle source
# File lib/cron_info/day_of_week_parser.rb, line 15
def parse_word_range(cron_string)
  first_word, last_word = cron_string.split("-")
  if day_of_week_mappings[first_word.downcase] == nil || day_of_week_mappings[last_word.downcase] == nil
    raise "Invalid day of week word range argument #{cron_string}"
  end
  (day_of_week_mappings[first_word.downcase]..day_of_week_mappings[last_word.downcase]).to_a
end