Class: Insika::Cron::Field
- Inherits:
-
Object
- Object
- Insika::Cron::Field
- Defined in:
- lib/insika/cron.rb
Overview
One field: the sorted accepted values + whether it was a bare "*" (the day-of-week OR rule needs to know which fields are restricted).
Instance Method Summary collapse
-
#at_or_after(start) ⇒ Object
-> Integer | nil: the smallest accepted value >= start (nil when none).
-
#initialize(expression, range, field:) ⇒ Field
constructor
A new instance of Field.
- #matches?(value) ⇒ Boolean
- #star? ⇒ Boolean
Constructor Details
#initialize(expression, range, field:) ⇒ Field
Returns a new instance of Field.
26 27 28 29 30 31 |
# File 'lib/insika/cron.rb', line 26 def initialize(expression, range, field:) @field = field @range = range @star = expression == "*" @values = expression.split(",").flat_map { |term| parse_term(term) }.uniq.sort end |
Instance Method Details
#at_or_after(start) ⇒ Object
-> Integer | nil: the smallest accepted value >= start (nil when none).
38 |
# File 'lib/insika/cron.rb', line 38 def at_or_after(start) = @values.find { |v| v >= start } |
#matches?(value) ⇒ Boolean
35 |
# File 'lib/insika/cron.rb', line 35 def matches?(value) = @values.include?(value) |
#star? ⇒ Boolean
33 |
# File 'lib/insika/cron.rb', line 33 def star? = @star |