Class: CronSpec::RangeCronValue
- Inherits:
-
CronValueBase
- Object
- CronValueBase
- CronSpec::RangeCronValue
- Defined in:
- lib/cron-spec/range_cron_value.rb
Overview
A cron value representing a range of values
Instance Attribute Summary collapse
-
#range_lower ⇒ Object
readonly
Returns the value of attribute range_lower.
-
#range_upper ⇒ Object
readonly
Returns the value of attribute range_upper.
Attributes inherited from CronValueBase
Instance Method Summary collapse
-
#initialize(lower_limit, upper_limit, range_lower, range_upper) ⇒ RangeCronValue
constructor
Constructs a new RangeCronValue object.
-
#is_effective?(value) ⇒ Boolean
Returns true if the specified value is with the range_upper/range_lower value range, inclusive.
Methods inherited from CronValueBase
Constructor Details
#initialize(lower_limit, upper_limit, range_lower, range_upper) ⇒ RangeCronValue
Constructs a new RangeCronValue object. The object is initialized with the value limits (lower_limit and upper_limit) and the defined sub-range of the lower/upper limits.
The range_lower and range_upper values are checked to determine if they are within the value limits and are not reversed. If they are not within limits or reversed an exception is raised.
19 20 21 22 23 24 25 26 27 |
# File 'lib/cron-spec/range_cron_value.rb', line 19 def initialize(lower_limit, upper_limit, range_lower, range_upper) super(lower_limit, upper_limit) @range_lower = range_lower @range_upper = range_upper raise "Invalid lower range value: #{@range_lower}" unless is_value_within_limits?(@range_lower) raise "Invalid upper range value: #{@range_upper}" unless is_value_within_limits?(@range_upper) raise "Lower limit must be less than or equal to the upper limit" if @range_lower > @range_upper end |
Instance Attribute Details
#range_lower ⇒ Object (readonly)
Returns the value of attribute range_lower.
8 9 10 |
# File 'lib/cron-spec/range_cron_value.rb', line 8 def range_lower @range_lower end |
#range_upper ⇒ Object (readonly)
Returns the value of attribute range_upper.
8 9 10 |
# File 'lib/cron-spec/range_cron_value.rb', line 8 def range_upper @range_upper end |
Instance Method Details
#is_effective?(value) ⇒ Boolean
Returns true if the specified value is with the range_upper/range_lower value range, inclusive.
33 34 35 |
# File 'lib/cron-spec/range_cron_value.rb', line 33 def is_effective?(value) @range_lower <= value && value <= @range_upper end |