Class: IceCube::WeeklyRule
- Defined in:
- lib/ice_cube/rules/weekly_rule.rb
Instance Attribute Summary
Attributes inherited from Rule
#occurrence_count, #until_date, #validations
Instance Method Summary collapse
-
#in_interval?(date, start_date) ⇒ Boolean
Determine whether or not this rule occurs on a given date.
- #to_ical ⇒ Object
- #to_s ⇒ Object
Methods inherited from Rule
#count, daily, from_hash, from_yaml, hourly, minutely, monthly, #next_suggestion, secondly, #to_hash, #to_yaml, #until, #validate_single_date, weekly, yearly
Methods included from ValidationTypes
#day, #day_of_month, #day_of_week, #day_of_year, #hour_of_day, #minute_of_hour, #month_of_year, #second_of_minute
Instance Method Details
#in_interval?(date, start_date) ⇒ Boolean
Determine whether or not this rule occurs on a given date. Weekly rules occurs if we’re in one of the interval weeks, and we’re in a valid day of the week.
8 9 10 11 12 13 |
# File 'lib/ice_cube/rules/weekly_rule.rb', line 8 def in_interval?(date, start_date) #make sure we're in the right interval date = adjust(date, start_date) week_of_year = Date.civil(date.year, date.month, date.day).cweek week_of_year % @interval == 0 end |
#to_ical ⇒ Object
15 16 17 |
# File 'lib/ice_cube/rules/weekly_rule.rb', line 15 def to_ical 'FREQ=WEEKLY' << to_ical_base end |
#to_s ⇒ Object
19 20 21 |
# File 'lib/ice_cube/rules/weekly_rule.rb', line 19 def to_s to_s_base 'Weekly', "Every #{@interval} weeks" end |