Class: IceCube::YearlyRule

Inherits:
Rule
  • Object
show all
Defined in:
lib/ice_cube/rules/yearly_rule.rb

Constant Summary

Constants inherited from Rule

Rule::SuggestionTypes

Instance Attribute Summary

Attributes inherited from Rule

#occurrence_count, #until_date, #validations

Instance Method Summary collapse

Methods inherited from Rule

#count, daily, from_hash, hourly, minutely, monthly, #next_suggestion, secondly, #to_hash, #to_s, #until, #validate_single_date, weekly, yearly

Methods included from HourOfDayValidation

#closest_hour_of_day, #hour_of_day, included, #validate_hour_of_day

Methods included from MinuteOfHourValidation

#closest_minute_of_hour, included, #minute_of_hour, #validate_minute_of_hour

Methods included from SecondOfMinuteValidation

#closest_second_of_minute, included, #second_of_minute, #validate_second_of_minute

Methods included from MonthOfYearValidation

#closest_month_of_year, included, #month_of_year, #validate_month_of_year

Methods included from DayOfYearValidation

#closest_day_of_year, #day_of_year, included, #validate_day_of_year

Methods included from DayOfMonthValidation

#closest_day_of_month, #day_of_month, included, #validate_day_of_month

Methods included from DayOfWeekValidation

#closest_day_of_week, #day_of_week, included, #validate_day_of_week

Methods included from DayValidation

#closest_day, #day, included, #validate_day

Instance Method Details

#in_interval?(date, start_date) ⇒ Boolean

Determine whether or not the rule, given a start_date, occurs on a given date. Yearly occurs if we’re in a proper interval and either (1) we’re on a day of the year, or (2) we’re on a month of the year as specified Note: rollover dates don’t work, so you can’t ask for the 400th day of a year and expect to roll into the next year (this might be a possible direction in the future)

Returns:

  • (Boolean)


11
12
13
14
# File 'lib/ice_cube/rules/yearly_rule.rb', line 11

def in_interval?(date, start_date)
  #make sure we're in the proper interval
  (date.year - start_date.year) % @interval == 0
end

#to_icalObject



16
17
18
# File 'lib/ice_cube/rules/yearly_rule.rb', line 16

def to_ical 
  'FREQ=YEARLY' << to_ical_base
end