Class: Cyclical::YearlyRule
- Defined in:
- lib/cyclical/rules/yearly_rule.rb
Overview
holds daily rule configuration
Instance Attribute Summary
Attributes inherited from Rule
Instance Method Summary collapse
-
#aligned?(time, base) ⇒ Boolean
check if time is aligned to a base time, including interval check.
-
#step ⇒ Object
default step of the rule.
Methods inherited from Rule
#count, daily, #filters, #finite?, from_hash, from_json, #infinite?, #initialize, #match?, #monthdays, monthly, #months, #next, #previous, #stop, #to_hash, #to_json, #weekdays, weekly, #yeardays, yearly
Constructor Details
This class inherits a constructor from Cyclical::Rule
Instance Method Details
#aligned?(time, base) ⇒ Boolean
check if time is aligned to a base time, including interval check
8 9 10 11 12 13 14 15 16 |
# File 'lib/cyclical/rules/yearly_rule.rb', line 8 def aligned?(time, base) return false unless (base.year - time.year).to_i % @interval == 0 return false unless [time.hour, time.min, time.sec] == [base.hour, base.min, base.sec] # the shortest filter we support is for days return false unless time.day == base.day || filters(:weekdays) || filters(:monthdays) || filters(:yeardays) return false unless time.month == base.month || filters(:yeardays) || filters(:weeks) || filters(:months) # wow, passed every test true end |
#step ⇒ Object
default step of the rule
19 20 21 |
# File 'lib/cyclical/rules/yearly_rule.rb', line 19 def step @interval.years end |