Class: IceCube::Validations::SecondlyInterval::Validation
- Inherits:
-
Object
- Object
- IceCube::Validations::SecondlyInterval::Validation
- Defined in:
- lib/ice_cube/validations/secondly_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.
18 19 20 |
# File 'lib/ice_cube/validations/secondly_interval.rb', line 18 def initialize(interval) @interval = interval end |
Instance Attribute Details
#interval ⇒ Object (readonly)
Returns the value of attribute interval.
16 17 18 |
# File 'lib/ice_cube/validations/secondly_interval.rb', line 16 def interval @interval end |
Instance Method Details
#build_hash(builder) ⇒ Object
40 41 42 |
# File 'lib/ice_cube/validations/secondly_interval.rb', line 40 def build_hash(builder) builder[:interval] = interval end |
#build_ical(builder) ⇒ Object
44 45 46 47 |
# File 'lib/ice_cube/validations/secondly_interval.rb', line 44 def build_ical(builder) builder['FREQ'] << 'SECONDLY' builder['INTERVAL'] << interval unless interval == 1 end |
#build_s(builder) ⇒ Object
36 37 38 |
# File 'lib/ice_cube/validations/secondly_interval.rb', line 36 def build_s(builder) builder.base = IceCube::I18n.t("ice_cube.each_second", count: interval) end |
#dst_adjust? ⇒ Boolean
26 27 28 |
# File 'lib/ice_cube/validations/secondly_interval.rb', line 26 def dst_adjust? false end |
#type ⇒ Object
22 23 24 |
# File 'lib/ice_cube/validations/secondly_interval.rb', line 22 def type :sec end |
#validate(step_time, start_time) ⇒ Object
30 31 32 33 34 |
# File 'lib/ice_cube/validations/secondly_interval.rb', line 30 def validate(step_time, start_time) seconds = step_time.to_i - start_time.to_i offset = (seconds % interval).nonzero? interval - offset if offset end |