Class: DateTimeStepWith::CronRangeMatcher

Inherits:
Object
  • Object
show all
Defined in:
lib/date_time_step_with/cron_matcher.rb

Overview

Copied from en.wikipedia.org/wiki/Cron

        • *

│ │ │ │ │ │ │ │ │ │ │ │ │ │ └───── day of week (0 - 6) (0 to 6 are Sunday to Saturday, or use names; 7 is Sunday, the same as 0) │ │ │ └────────── month (1 - 12) │ │ └─────────────── day of month (1 - 31) │ └──────────────────── hour (0 - 23) └───────────────────────── min (0 - 59)

Instance Method Summary collapse

Constructor Details

#initialize(cron_expression) ⇒ CronRangeMatcher

Returns a new instance of CronRangeMatcher.



13
14
15
16
# File 'lib/date_time_step_with/cron_matcher.rb', line 13

def initialize(cron_expression)
  from, to = cron_expression.split("-")
  @range = (from..to).to_a
end

Instance Method Details

#=~(value) ⇒ Object



18
19
20
# File 'lib/date_time_step_with/cron_matcher.rb', line 18

def =~(value)
  @range.include? value
end