class When::CronPart
Constants
- REMAP
Public Class Methods
new(cron_part)
click to toggle source
# File lib/when-cron/cron/cron_part.rb, line 28 def initialize(cron_part) @cron_part = cron_part @part = parse(cron_part) end
Public Instance Methods
==(int)
click to toggle source
# File lib/when-cron/cron/cron_part.rb, line 33 def ==(int) @part ||= parse(@cron_part) @part == int end
wildcard?()
click to toggle source
# File lib/when-cron/cron/cron_part.rb, line 38 def wildcard? @part.kind_of? Wildcard end
Private Instance Methods
parse(cron_part)
click to toggle source
# File lib/when-cron/cron/cron_part.rb, line 44 def parse(cron_part) if cron_part =~ /,/ CronArray.new(cron_part.split(',').map { |s| parse(s) }) elsif cron_part =~ /\// CronInterval.new(*cron_part.split('/').map { |s| parse(s) }) elsif cron_part =~ /-/ CronRange.new(*cron_part.split('-').map { |s| parse(s) }) elsif cron_part == '*' Wildcard.new else to_int(cron_part) end end
to_int(cron_part)
click to toggle source
# File lib/when-cron/cron/cron_part.rb, line 58 def to_int(cron_part) to_valid_int(REMAP[cron_part.upcase] || cron_part) end
to_valid_int(cron_part)
click to toggle source
# File lib/when-cron/cron/cron_part.rb, line 62 def to_valid_int(cron_part) int = cron_part.to_i if int.to_s == cron_part int else raise When::CronPart::InvalidString, "found #{cron_part.inspect}: only * or integer values and / , - operators are supported" end end