Class: IceCube::Validations::YearlyInterval::Validation
- Inherits:
-
Object
- Object
- IceCube::Validations::YearlyInterval::Validation
- Defined in:
- lib/ice_cube/validations/yearly_interval.rb
Instance Attribute Summary collapse
-
#interval ⇒ Object
readonly
Returns the value of attribute interval.
Instance Method Summary collapse
- #build_hash(builder) ⇒ Object
- #build_ical(builder) ⇒ Object
- #build_s(builder) ⇒ Object
- #dst_adjust? ⇒ Boolean
-
#initialize(interval) ⇒ Validation
constructor
A new instance of Validation.
- #type ⇒ Object
- #validate(step_time, schedule) ⇒ Object
Constructor Details
#initialize(interval) ⇒ Validation
Returns a new instance of Validation.
16 17 18 |
# File 'lib/ice_cube/validations/yearly_interval.rb', line 16 def initialize(interval) @interval = interval end |
Instance Attribute Details
#interval ⇒ Object (readonly)
Returns the value of attribute interval.
14 15 16 |
# File 'lib/ice_cube/validations/yearly_interval.rb', line 14 def interval @interval end |
Instance Method Details
#build_hash(builder) ⇒ Object
38 39 40 |
# File 'lib/ice_cube/validations/yearly_interval.rb', line 38 def build_hash(builder) builder[:interval] = interval end |
#build_ical(builder) ⇒ Object
42 43 44 45 46 47 |
# File 'lib/ice_cube/validations/yearly_interval.rb', line 42 def build_ical(builder) builder['FREQ'] << 'YEARLY' unless interval == 1 builder['INTERVAL'] << interval end end |
#build_s(builder) ⇒ Object
34 35 36 |
# File 'lib/ice_cube/validations/yearly_interval.rb', line 34 def build_s(builder) builder.base = IceCube::I18n.t('ice_cube.each_year', count: interval) end |
#dst_adjust? ⇒ Boolean
24 25 26 |
# File 'lib/ice_cube/validations/yearly_interval.rb', line 24 def dst_adjust? true end |
#type ⇒ Object
20 21 22 |
# File 'lib/ice_cube/validations/yearly_interval.rb', line 20 def type :year end |
#validate(step_time, schedule) ⇒ Object
28 29 30 31 32 |
# File 'lib/ice_cube/validations/yearly_interval.rb', line 28 def validate(step_time, schedule) years = step_time.year - schedule.start_time.year offset = (years % interval).nonzero? interval - offset if offset end |