Module: DateTimeStepWith::CronMatcher
- Defined in:
- lib/date_time_step_with/cron_matcher.rb
Constant Summary collapse
- @@cron_re_exps =
{}
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.included(klass) ⇒ Object
50 51 52 53 54 55 56 |
# File 'lib/date_time_step_with/cron_matcher.rb', line 50 def self.included(klass) if (klass == Date) klass.include CronMatcherDateMethods else klass.include CronMatcherTimeMethods end end |
Instance Method Details
#match_cron?(cron_expression) ⇒ Boolean
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/date_time_step_with/cron_matcher.rb', line 58 def match_cron?(cron_expression) @@cron_re_exps[cron_expression] ||= cron_expression.split(/\s/).collect {|cr_exp| if (cr_exp == "*") /.*/ elsif cr_exp["-"] CronRangeMatcher.new(cr_exp) elsif cr_exp[","] CronListMatcher.new(cr_exp) else Regexp.new("^#{cr_exp.to_i}$") end } self_cron_array.zip(@@cron_re_exps[cron_expression]).all? do |value, cr_exp| cr_exp =~ value end end |