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.
17 18 19 |
# File 'lib/ice_cube/validations/day_of_year.rb', line 17 def initialize(day) @day = day end |
Instance Attribute Details
#day ⇒ Object (readonly)
Returns the value of attribute day.
15 16 17 |
# File 'lib/ice_cube/validations/day_of_year.rb', line 15 def day @day end |
Instance Method Details
#build_hash(builder) ⇒ Object
40 41 42 |
# File 'lib/ice_cube/validations/day_of_year.rb', line 40 def build_hash(builder) builder.validations_array(:day_of_year) << day end |
#build_ical(builder) ⇒ Object
44 45 46 |
# File 'lib/ice_cube/validations/day_of_year.rb', line 44 def build_ical(builder) builder["BYYEARDAY"] << day end |
#build_s(builder) ⇒ Object
36 37 38 |
# File 'lib/ice_cube/validations/day_of_year.rb', line 36 def build_s(builder) builder.piece(:day_of_year) << StringBuilder.nice_number(day) end |
#dst_adjust? ⇒ Boolean
25 26 27 |
# File 'lib/ice_cube/validations/day_of_year.rb', line 25 def dst_adjust? true end |
#type ⇒ Object
21 22 23 |
# File 'lib/ice_cube/validations/day_of_year.rb', line 21 def type :day end |
#validate(step_time, start_time) ⇒ Object
29 30 31 32 33 34 |
# File 'lib/ice_cube/validations/day_of_year.rb', line 29 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 |