Class: CronSpec::SingleValueCronValue

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

Overview

A single cron value

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, single_value) ⇒ SingleValueCronValue

Constructs a new SingleValueCronValue having the specified limits and value. The value is checked to determine if it fits within the specified limits; if it doesn’t, an exception is raised.



15
16
17
18
19
20
21
# File 'lib/cron-spec/single_value_cron_value.rb', line 15

def initialize(lower_limit, upper_limit, single_value)
  super(lower_limit, upper_limit)

  @single_value = single_value

  raise "Value is out of range: #{@single_value}" unless is_value_within_limits?(@single_value)
end

Instance Attribute Details

#single_valueObject (readonly)

Returns the value of attribute single_value.



8
9
10
# File 'lib/cron-spec/single_value_cron_value.rb', line 8

def single_value
  @single_value
end

Instance Method Details

#is_effective?(value) ⇒ Boolean

Returns true if the specified value is equal to the value encapsulated by the SingleValueCronValue.

Returns:

  • (Boolean)


27
28
29
# File 'lib/cron-spec/single_value_cron_value.rb', line 27

def is_effective?(value)
  @single_value == value
end