Class: CronSpec::CronValueBase

Inherits:
Object
  • Object
show all
Defined in:
lib/cron-spec/cron_value_base.rb

Overview

Base class for parsed cron values.

Instance Attribute Summary collapse

Instance Method Summary collapse

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_limitObject (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_limitObject (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.

Returns:

  • (Boolean)


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