Module: IceCube::Validations::Day

Included in:
DailyRule, HourlyRule, MinutelyRule, MonthlyRule, SecondlyRule, WeeklyRule, YearlyRule
Defined in:
lib/ice_cube/validations/day.rb

Defined Under Namespace

Classes: Validation

Instance Method Summary collapse

Instance Method Details

#day(*days) ⇒ Object



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

def day(*days)
  days = days.flatten
  return self if days.empty?
  days.flatten.each do |day|
    unless day.is_a?(Integer) || day.is_a?(Symbol)
      raise ArgumentError, "expecting Integer or Symbol value for day, got #{day.inspect}"
    end
    day = TimeUtil.sym_to_wday(day)
    verify_alignment(day, :wday, :day) { |error| raise error }

    validations_for(:day) << Validation.new(day)
  end
  clobber_base_validations(:wday, :day)
  self
end