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

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

Overview

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

#fixed_day?Boolean

Returns:

  • (Boolean)


44
45
46
# File 'lib/ri_cal/property_value/recurrence_rule/recurring_month_day.rb', line 44

def fixed_day?
  @source > 0
end

#include?(date_or_time) ⇒ Boolean

Returns:

  • (Boolean)


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

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

#lastObject

:nodoc:



7
8
9
# File 'lib/ri_cal/property_value/recurrence_rule/recurring_month_day.rb', line 7

def last
  31
end

#list_id(time) ⇒ Object

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



12
13
14
# File 'lib/ri_cal/property_value/recurrence_rule/recurring_month_day.rb', line 12

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



17
18
19
# File 'lib/ri_cal/property_value/recurrence_rule/recurring_month_day.rb', line 17

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

#target_date_time_for(date_time) ⇒ Object



31
32
33
# File 'lib/ri_cal/property_value/recurrence_rule/recurring_month_day.rb', line 31

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

#target_for(date_or_time) ⇒ Object



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

def target_for(date_or_time)
  if fixed_day?
    @source
  else
    date_or_time.days_in_month + @source + 1
  end
end