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

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

Overview

:nodoc:

Instance Attribute Summary collapse

Attributes inherited from FrequencyIncrementer

#interval, #outer_occurrence, #skip_increment

Attributes inherited from 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

Methods inherited from 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.



748
749
750
751
# File 'lib/ri_cal/property_value/recurrence_rule/occurence_incrementer.rb', line 748

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

Instance Attribute Details

#wkstObject (readonly)

Returns the value of attribute wkst.



746
747
748
# File 'lib/ri_cal/property_value/recurrence_rule/occurence_incrementer.rb', line 746

def wkst
  @wkst
end

Class Method Details

.from_rrule(rrule, start_time) ⇒ Object



753
754
755
# File 'lib/ri_cal/property_value/recurrence_rule/occurence_incrementer.rb', line 753

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

Instance Method Details

#advance_whatObject



757
758
759
# File 'lib/ri_cal/property_value/recurrence_rule/occurence_incrementer.rb', line 757

def advance_what
  :years
end

#end_of_occurrence(date_time) ⇒ Object



783
784
785
786
787
788
789
# File 'lib/ri_cal/property_value/recurrence_rule/occurence_incrementer.rb', line 783

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



773
774
775
776
777
778
779
780
781
# File 'lib/ri_cal/property_value/recurrence_rule/occurence_incrementer.rb', line 773

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



761
762
763
764
765
766
767
768
769
770
771
# File 'lib/ri_cal/property_value/recurrence_rule/occurence_incrementer.rb', line 761

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