Class: CronSpec::CronValueBase
- Inherits:
-
Object
- Object
- CronSpec::CronValueBase
- Defined in:
- lib/cron-spec/cron_value_base.rb
Overview
Base class for parsed cron values.
Direct Known Subclasses
RangeCronValue, SingleValueCronValue, StepCronValue, WildcardCronValue
Instance Attribute Summary collapse
-
#lower_limit ⇒ Object
readonly
Returns the value of attribute lower_limit.
-
#upper_limit ⇒ Object
readonly
Returns the value of attribute upper_limit.
Instance Method Summary collapse
-
#initialize(lower_limit, upper_limit) ⇒ CronValueBase
constructor
Constructs a new CronValueBase with the upper and lower limits of values allowed for this CronValue.
-
#is_value_within_limits?(value) ⇒ Boolean
Returns true if the specified value is with the upper and lower limits defined for this CronValue.
Constructor Details
#initialize(lower_limit, upper_limit) ⇒ CronValueBase
Constructs a new CronValueBase with the upper and lower limits of values allowed for this CronValue. For example, when definiting a CronValue for a ‘minute’, the lower limit would be 0 and the upper limit would be 59.
16 17 18 19 20 21 |
# File 'lib/cron-spec/cron_value_base.rb', line 16 def initialize(lower_limit, upper_limit) @lower_limit = lower_limit @upper_limit = upper_limit raise "Lower limit must be less than or equal to upper limit" if @lower_limit > @upper_limit end |
Instance Attribute Details
#lower_limit ⇒ Object (readonly)
Returns the value of attribute lower_limit.
8 9 10 |
# File 'lib/cron-spec/cron_value_base.rb', line 8 def lower_limit @lower_limit end |
#upper_limit ⇒ Object (readonly)
Returns the value of attribute upper_limit.
8 9 10 |
# File 'lib/cron-spec/cron_value_base.rb', line 8 def upper_limit @upper_limit end |
Instance Method Details
#is_value_within_limits?(value) ⇒ Boolean
Returns true if the specified value is with the upper and lower limits defined for this CronValue.
27 28 29 |
# File 'lib/cron-spec/cron_value_base.rb', line 27 def is_value_within_limits?(value) value >= @lower_limit && value <= upper_limit end |