Class: RiCal::PropertyValue::RecurrenceRule::OccurrenceIncrementer::YearlyIncrementer

Inherits:
FrequencyIncrementer show all
Defined in:
lib/ri_cal/property_value/recurrence_rule/occurrence_incrementer/yearly_incrementer.rb

Overview

:nodoc:

Instance Attribute Summary collapse

Attributes inherited from FrequencyIncrementer

#interval, #outer_occurrence, #skip_increment

Attributes inherited from RiCal::PropertyValue::RecurrenceRule::OccurrenceIncrementer

#contains_daily_incrementer, #contains_weeknum_incrementer, #current_occurrence, #leaf_iterator, #outer_incrementers, #outer_range, #sub_cycle_incrementer

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from FrequencyIncrementer

conditional_incrementer, #first_within_outer_cycle, #multiplier, #next_cycle, #sub_cycle_incrementer

Methods inherited from RiCal::PropertyValue::RecurrenceRule::OccurrenceIncrementer

#add_outer_incrementer, #contains_daily_incrementer?, #contains_weeknum_incrementer?, #daily_incrementer?, #first_sub_occurrence, #in_outer_cycle?, #next_cycle, #next_time, #outermost?, #short_name, #to_s, #update_cycle_range, #weeknum_incrementer?

Methods included from TimeManipulation

#advance_day, #advance_month, #advance_week, #advance_year, #first_day_of_month, #first_day_of_week, #first_day_of_year, #first_hour_of_day

Constructor Details

#initialize(rrule, sub_cycle_incrementer) ⇒ YearlyIncrementer

Returns a new instance of YearlyIncrementer.



11
12
13
14
# File 'lib/ri_cal/property_value/recurrence_rule/occurrence_incrementer/yearly_incrementer.rb', line 11

def initialize(rrule, sub_cycle_incrementer)
  @wkst = rrule.wkst_day
  super(rrule, sub_cycle_incrementer)
end

Instance Attribute Details

#wkstObject (readonly)

:nodoc:



9
10
11
# File 'lib/ri_cal/property_value/recurrence_rule/occurrence_incrementer/yearly_incrementer.rb', line 9

def wkst
  @wkst
end

Class Method Details

.from_rrule(rrule, start_time) ⇒ Object



16
17
18
# File 'lib/ri_cal/property_value/recurrence_rule/occurrence_incrementer/yearly_incrementer.rb', line 16

def self.from_rrule(rrule, start_time)
  conditional_incrementer(rrule, "YEARLY", ByMonthIncrementer)
end

Instance Method Details

#advance_whatObject



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

def advance_what
  :years
end

#end_of_occurrence(date_time) ⇒ Object



46
47
48
49
50
51
52
# File 'lib/ri_cal/property_value/recurrence_rule/occurrence_incrementer/yearly_incrementer.rb', line 46

def end_of_occurrence(date_time)
  if contains_weeknum_incrementer?
    date_time.end_of_iso_year(wkst)
  else
    date_time.end_of_year
  end
end

#start_of_cycle(date_time) ⇒ Object



36
37
38
39
40
41
42
43
44
# File 'lib/ri_cal/property_value/recurrence_rule/occurrence_incrementer/yearly_incrementer.rb', line 36

def start_of_cycle(date_time)
  if contains_weeknum_incrementer?
    date_time.at_start_of_iso_year(wkst)
  elsif contains_daily_incrementer?
    date_time.change(:month => 1, :day => 1)
  else
    date_time.change(:month => 1)
  end
end

#step(date_time) ⇒ Object



24
25
26
27
28
29
30
31
32
33
34
# File 'lib/ri_cal/property_value/recurrence_rule/occurrence_incrementer/yearly_incrementer.rb', line 24

def step(date_time)
  if contains_weeknum_incrementer?
    result = date_time
    multiplier.times do
      result = result.at_start_of_next_iso_year(wkst)
    end
    result
  else
    super(date_time)
  end
end