Class: IceCube::Validations::DayOfYear::Validation
- Inherits:
-
Object
- Object
- IceCube::Validations::DayOfYear::Validation
- Defined in:
- lib/ice_cube/validations/day_of_year.rb
Instance Attribute Summary collapse
-
#day ⇒ Object
readonly
Returns the value of attribute day.
Instance Method Summary collapse
- #build_hash(builder) ⇒ Object
- #build_ical(builder) ⇒ Object
- #build_s(builder) ⇒ Object
- #dst_adjust? ⇒ Boolean
-
#initialize(day) ⇒ Validation
constructor
A new instance of Validation.
- #type ⇒ Object
- #validate(step_time, start_time) ⇒ Object
Constructor Details
#initialize(day) ⇒ Validation
Returns a new instance of Validation.
20 21 22 |
# File 'lib/ice_cube/validations/day_of_year.rb', line 20 def initialize(day) @day = day end |
Instance Attribute Details
#day ⇒ Object (readonly)
Returns the value of attribute day.
18 19 20 |
# File 'lib/ice_cube/validations/day_of_year.rb', line 18 def day @day end |
Instance Method Details
#build_hash(builder) ⇒ Object
43 44 45 |
# File 'lib/ice_cube/validations/day_of_year.rb', line 43 def build_hash(builder) builder.validations_array(:day_of_year) << day end |
#build_ical(builder) ⇒ Object
47 48 49 |
# File 'lib/ice_cube/validations/day_of_year.rb', line 47 def build_ical(builder) builder['BYYEARDAY'] << day end |
#build_s(builder) ⇒ Object
39 40 41 |
# File 'lib/ice_cube/validations/day_of_year.rb', line 39 def build_s(builder) builder.piece(:day_of_year) << StringBuilder.nice_number(day) end |
#dst_adjust? ⇒ Boolean
28 29 30 |
# File 'lib/ice_cube/validations/day_of_year.rb', line 28 def dst_adjust? true end |
#type ⇒ Object
24 25 26 |
# File 'lib/ice_cube/validations/day_of_year.rb', line 24 def type :day end |
#validate(step_time, start_time) ⇒ Object
32 33 34 35 36 37 |
# File 'lib/ice_cube/validations/day_of_year.rb', line 32 def validate(step_time, start_time) days_in_year = TimeUtil.days_in_year(step_time) yday = day < 0 ? day + days_in_year + 1 : day offset = yday - step_time.yday offset >= 0 ? offset : offset + days_in_year end |