Class: IceCube::Validations::Day::Validation

Inherits:
Object
  • Object
show all
Includes:
Lock
Defined in:
lib/ice_cube/validations/day.rb

Constant Summary

Constants included from Lock

Lock::INTERVALS

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Lock

#validate

Constructor Details

#initialize(day) ⇒ Validation

Returns a new instance of Validation.



23
24
25
# File 'lib/ice_cube/validations/day.rb', line 23

def initialize(day)
  @day = day
end

Instance Attribute Details

#dayObject (readonly) Also known as: value

Returns the value of attribute day.



20
21
22
# File 'lib/ice_cube/validations/day.rb', line 20

def day
  @day
end

Instance Method Details

#build_hash(builder) ⇒ Object



31
32
33
# File 'lib/ice_cube/validations/day.rb', line 31

def build_hash(builder)
  builder.validations_array(:day) << day
end

#build_ical(builder) ⇒ Object



35
36
37
38
39
40
41
# File 'lib/ice_cube/validations/day.rb', line 35

def build_ical(builder)
  ical_day = IcalBuilder.fixnum_to_ical_day(day)
  # Only add if there aren't others from day_of_week that override
  if builder['BYDAY'].none? { |b| b.end_with?(ical_day) }
    builder['BYDAY'] << ical_day
  end
end

#build_s(builder) ⇒ Object



27
28
29
# File 'lib/ice_cube/validations/day.rb', line 27

def build_s(builder)
  builder.piece(:day) << day
end

#typeObject



43
44
45
# File 'lib/ice_cube/validations/day.rb', line 43

def type
  :wday
end