Class: Cyclical::WeeklyRule
- Defined in:
- lib/cyclical/rules/weekly_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/weekly_rule.rb', line 8 def aligned?(time, base) return false unless ((base.beginning_of_week - time.beginning_of_week) / 604800).to_i % @interval == 0 # 604800 = 7.days 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.wday == time.wday || weekday_filters # wow, passed every test true end |
#step ⇒ Object
default step of the rule
19 20 21 |
# File 'lib/cyclical/rules/weekly_rule.rb', line 19 def step @interval.weeks end |