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, start_time) ⇒ Object
Constructor Details
#initialize(interval) ⇒ Validation
Returns a new instance of Validation.
13 14 15 |
# File 'lib/ice_cube/validations/yearly_interval.rb', line 13 def initialize(interval) @interval = interval end |
Instance Attribute Details
#interval ⇒ Object (readonly)
Returns the value of attribute interval.
11 12 13 |
# File 'lib/ice_cube/validations/yearly_interval.rb', line 11 def interval @interval end |
Instance Method Details
#build_hash(builder) ⇒ Object
35 36 37 |
# File 'lib/ice_cube/validations/yearly_interval.rb', line 35 def build_hash(builder) builder[:interval] = interval end |
#build_ical(builder) ⇒ Object
39 40 41 42 43 44 |
# File 'lib/ice_cube/validations/yearly_interval.rb', line 39 def build_ical(builder) builder["FREQ"] << "YEARLY" unless interval == 1 builder["INTERVAL"] << interval end end |
#build_s(builder) ⇒ Object
31 32 33 |
# File 'lib/ice_cube/validations/yearly_interval.rb', line 31 def build_s(builder) builder.base = IceCube::I18n.t("ice_cube.each_year", count: interval) end |
#dst_adjust? ⇒ Boolean
21 22 23 |
# File 'lib/ice_cube/validations/yearly_interval.rb', line 21 def dst_adjust? true end |
#type ⇒ Object
17 18 19 |
# File 'lib/ice_cube/validations/yearly_interval.rb', line 17 def type :year end |
#validate(step_time, start_time) ⇒ Object
25 26 27 28 29 |
# File 'lib/ice_cube/validations/yearly_interval.rb', line 25 def validate(step_time, start_time) years = step_time.year - start_time.year offset = (years % interval).nonzero? interval - offset if offset end |