Class: CronSpec::RangeCronValue

Inherits:
CronValueBase show all
Defined in:
lib/cron-spec/range_cron_value.rb

Instance Attribute Summary collapse

Attributes inherited from CronValueBase

#lower_limit, #upper_limit

Instance Method Summary collapse

Methods inherited from CronValueBase

#is_value_within_limits?

Constructor Details

#initialize(lower_limit, upper_limit, range_lower, range_upper) ⇒ RangeCronValue



7
8
9
10
11
12
13
14
15
# File 'lib/cron-spec/range_cron_value.rb', line 7

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_lowerObject (readonly)

Returns the value of attribute range_lower.



5
6
7
# File 'lib/cron-spec/range_cron_value.rb', line 5

def range_lower
  @range_lower
end

#range_upperObject (readonly)

Returns the value of attribute range_upper.



5
6
7
# File 'lib/cron-spec/range_cron_value.rb', line 5

def range_upper
  @range_upper
end

Instance Method Details

#is_effective?(value) ⇒ Boolean



17
18
19
# File 'lib/cron-spec/range_cron_value.rb', line 17

def is_effective?(value)
  @range_lower <= value && value <= @range_upper
end