Class: Cyclical::MonthlyRule
- Defined in:
- lib/cyclical/rules/monthly_rule.rb
Overview
holds weekly 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 |
# File 'lib/cyclical/rules/monthly_rule.rb', line 8 def aligned?(time, base) return false unless ((12 * base.year + base.mon) - (12 * time.year + time.mon)) % @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 base.day == time.day || monthday_filters true end |
#step ⇒ Object
default step of the rule
17 18 19 |
# File 'lib/cyclical/rules/monthly_rule.rb', line 17 def step @interval.months end |