class IceCube::Validations::HourlyInterval::Validation
Attributes
interval[R]
Public Class Methods
new(interval)
click to toggle source
# File lib/ice_cube/validations/hourly_interval.rb, line 18 def initialize(interval) @interval = interval end
Public Instance Methods
build_hash(builder)
click to toggle source
# File lib/ice_cube/validations/hourly_interval.rb, line 43 def build_hash(builder) builder[:interval] = interval end
build_ical(builder)
click to toggle source
# File lib/ice_cube/validations/hourly_interval.rb, line 47 def build_ical(builder) builder['FREQ'] << 'HOURLY' builder['INTERVAL'] << interval unless interval == 1 end
build_s(builder)
click to toggle source
# File lib/ice_cube/validations/hourly_interval.rb, line 39 def build_s(builder) builder.base = IceCube::I18n.t("ice_cube.each_hour", count: interval) end
dst_adjust?()
click to toggle source
# File lib/ice_cube/validations/hourly_interval.rb, line 26 def dst_adjust? false end
type()
click to toggle source
# File lib/ice_cube/validations/hourly_interval.rb, line 22 def type :hour end
validate(step_time, start_time)
click to toggle source
# File lib/ice_cube/validations/hourly_interval.rb, line 30 def validate(step_time, start_time) t0, t1 = start_time.to_i, step_time.to_i sec = (t1 - t1 % ONE_HOUR) - (t0 - t0 % ONE_HOUR) hours = sec / ONE_HOUR offset = (hours % interval).nonzero? interval - offset if offset end