Module: IceCubeEx::Validations::DayCycleInterval

Included in:
DayCycleRule
Defined in:
lib/ice_cube_ex/validations/day_cycle_interval.rb

Defined Under Namespace

Classes: Validation

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#ruleObject

Returns the value of attribute rule.



4
5
6
# File 'lib/ice_cube_ex/validations/day_cycle_interval.rb', line 4

def rule
  @rule
end

Instance Method Details

#cycle(cycle, repeat) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/ice_cube_ex/validations/day_cycle_interval.rb', line 6

def cycle(cycle, repeat)
  @interval = 1
  @repeat   = normalize(repeat)
  @cycle    = normalize(cycle)

  unless @repeat < @cycle
    raise ArgumentError, 'cycle has to be a value higher than repeat'
  end

  @acceptable_cycle_percentage = ((@repeat.to_f / @cycle.to_f) * 100).to_i
  replace_validations_for \
    :interval, [Validation.new(@interval, @cycle, @repeat)]
  clobber_base_validations(:wday, :day)
  self
end