Class: RiCal::PropertyValue::RecurrenceRule::RecurringMonthDay

Inherits:
NumberedSpan show all
Defined in:
lib/ri_cal/property_value/recurrence_rule/recurring_month_day.rb

Overview

  • ©2009 Rick DeNatale

  • All rights reserved. Refer to the file README.txt for the license

Instances of RecurringMonthDay represent BYMONTHDAY parts in recurrence rules

Instance Attribute Summary

Attributes inherited from NumberedSpan

#source

Instance Method Summary collapse

Methods inherited from NumberedSpan

#==, #initialize, #ordinal, #to_s, #valid?

Constructor Details

This class inherits a constructor from RiCal::PropertyValue::RecurrenceRule::NumberedSpan

Instance Method Details

#include?(date_or_time) ⇒ Boolean

Returns:

  • (Boolean)


55
56
57
# File 'lib/ri_cal/property_value/recurrence_rule/recurring_month_day.rb', line 55

def include?(date_or_time)
  date_or_time.mday == target_for(date_or_time)
end

#lastObject

:nodoc:



10
11
12
# File 'lib/ri_cal/property_value/recurrence_rule/recurring_month_day.rb', line 10

def last
  31
end

#list_id(time) ⇒ Object

return a list id for a given time to allow the enumerator to cache lists



15
16
17
# File 'lib/ri_cal/property_value/recurrence_rule/recurring_month_day.rb', line 15

def list_id(time)
  time.month
end

#matches_for(time) ⇒ Object

return a list of times which match the time parameter within the scope of the RecurringDay



20
21
22
# File 'lib/ri_cal/property_value/recurrence_rule/recurring_month_day.rb', line 20

def matches_for(time)
  [time.change(:day => 1).advance(:days => target_for(time)- 1)]
end

#target_date_time_for(date_time) ⇒ Object



34
35
36
# File 'lib/ri_cal/property_value/recurrence_rule/recurring_month_day.rb', line 34

def target_date_time_for(date_time)
  matches_for(date_time)[0]
end

#target_for(date_or_time) ⇒ Object



47
48
49
50
51
52
53
# File 'lib/ri_cal/property_value/recurrence_rule/recurring_month_day.rb', line 47

def target_for(date_or_time)
  if @source > 0
    @source
  else
    date_or_time.days_in_month + @source + 1
  end
end