Class: CronSpec::StepCronValue
- Inherits:
-
CronValueBase
- Object
- CronValueBase
- CronSpec::StepCronValue
- Defined in:
- lib/cron-spec/step_cron_value.rb
Overview
Defines an instance of a step value within a cron specification.
Instance Attribute Summary collapse
-
#step_value ⇒ Object
readonly
Returns the value of attribute step_value.
Attributes inherited from CronValueBase
Instance Method Summary collapse
-
#initialize(lower_limit, upper_limit, step_value) ⇒ StepCronValue
constructor
Constructs a new StepCronValue with the specified lower and upper limits and step value.
-
#is_effective?(value) ⇒ Boolean
Returns true if the specified value represents a value step value within the step specification.
Methods inherited from CronValueBase
Constructor Details
#initialize(lower_limit, upper_limit, step_value) ⇒ StepCronValue
Constructs a new StepCronValue with the specified lower and upper limits and step value. If the step value is 0 or is not less than or equal to the upper limit, an exception is raised.
15 16 17 18 19 20 21 |
# File 'lib/cron-spec/step_cron_value.rb', line 15 def initialize(lower_limit, upper_limit, step_value) super(lower_limit, upper_limit) @step_value = step_value raise "Invalid step value: #{@step_value}" if step_value == 0 || step_value > upper_limit end |
Instance Attribute Details
#step_value ⇒ Object (readonly)
Returns the value of attribute step_value.
8 9 10 |
# File 'lib/cron-spec/step_cron_value.rb', line 8 def step_value @step_value end |
Instance Method Details
#is_effective?(value) ⇒ Boolean
Returns true if the specified value represents a value step value within the step specification. Verifies that value % step_value == 0
27 28 29 |
# File 'lib/cron-spec/step_cron_value.rb', line 27 def is_effective?(value) value % @step_value == 0 end |