Class: RiCal::PropertyValue::RecurrenceRule::OccurrenceIncrementer::FrequencyIncrementer
- Inherits:
-
RiCal::PropertyValue::RecurrenceRule::OccurrenceIncrementer
- Object
- RiCal::PropertyValue::RecurrenceRule::OccurrenceIncrementer
- RiCal::PropertyValue::RecurrenceRule::OccurrenceIncrementer::FrequencyIncrementer
- Defined in:
- lib/ri_cal/property_value/recurrence_rule/occurrence_incrementer/frequency_incrementer.rb
Overview
A FrequenceIncrementer represents the xxxLY and FREQ parts of a recurrence rule A FrequenceIncrementer has a single occurrence within each cycle.
Direct Known Subclasses
DailyIncrementer, HourlyIncrementer, MinutelyIncrementer, MonthlyIncrementer, SecondlyIncrementer, WeeklyIncrementer, YearlyIncrementer
Instance Attribute Summary collapse
-
#interval ⇒ Object
:nodoc:.
-
#outer_occurrence ⇒ Object
:nodoc:.
-
#skip_increment ⇒ Object
:nodoc:.
Attributes inherited from RiCal::PropertyValue::RecurrenceRule::OccurrenceIncrementer
#contains_daily_incrementer, #contains_weeknum_incrementer, #current_occurrence, #leaf_iterator, #outer_incrementers, #outer_range
Class Method Summary collapse
Instance Method Summary collapse
- #first_within_outer_cycle(previous_occurrence, outer_cycle_range) ⇒ Object
-
#initialize(rrule, sub_cycle_incrementer) ⇒ FrequencyIncrementer
constructor
A new instance of FrequencyIncrementer.
- #multiplier ⇒ Object
-
#next_cycle(previous_occurrence) ⇒ Object
Advance to the next occurrence, if the result is within the current cycles of all outer incrementers.
- #step(occurrence) ⇒ Object
- #sub_cycle_incrementer ⇒ Object
Methods inherited from RiCal::PropertyValue::RecurrenceRule::OccurrenceIncrementer
#add_outer_incrementer, #contains_daily_incrementer?, #contains_weeknum_incrementer?, #daily_incrementer?, #first_sub_occurrence, from_rrule, #in_outer_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) ⇒ FrequencyIncrementer
Returns a new instance of FrequencyIncrementer.
15 16 17 18 |
# File 'lib/ri_cal/property_value/recurrence_rule/occurrence_incrementer/frequency_incrementer.rb', line 15 def initialize(rrule, sub_cycle_incrementer) super(rrule, sub_cycle_incrementer) self.interval = rrule.interval end |
Instance Attribute Details
#interval ⇒ Object
:nodoc:
11 12 13 |
# File 'lib/ri_cal/property_value/recurrence_rule/occurrence_incrementer/frequency_incrementer.rb', line 11 def interval @interval end |
#outer_occurrence ⇒ Object
:nodoc:
11 12 13 |
# File 'lib/ri_cal/property_value/recurrence_rule/occurrence_incrementer/frequency_incrementer.rb', line 11 def outer_occurrence @outer_occurrence end |
#skip_increment ⇒ Object
:nodoc:
11 12 13 |
# File 'lib/ri_cal/property_value/recurrence_rule/occurrence_incrementer/frequency_incrementer.rb', line 11 def skip_increment @skip_increment end |
Class Method Details
.conditional_incrementer(rrule, freq_str, sub_cycle_class) ⇒ Object
20 21 22 23 24 25 26 27 |
# File 'lib/ri_cal/property_value/recurrence_rule/occurrence_incrementer/frequency_incrementer.rb', line 20 def self.conditional_incrementer(rrule, freq_str, sub_cycle_class) sub_cycle_incrementer = sub_cycle_class.for_rrule(rrule) if rrule.freq == freq_str new(rrule, sub_cycle_incrementer) else sub_cycle_incrementer end end |
Instance Method Details
#first_within_outer_cycle(previous_occurrence, outer_cycle_range) ⇒ Object
45 46 47 48 49 50 51 52 53 |
# File 'lib/ri_cal/property_value/recurrence_rule/occurrence_incrementer/frequency_incrementer.rb', line 45 def first_within_outer_cycle(previous_occurrence, outer_cycle_range) if outer_range first_occurrence = outer_cycle_range.first else first_occurrence = step(previous_occurrence) end self.outer_range = outer_cycle_range sub_cycle_incrementer.first_within_outer_cycle(previous_occurrence, update_cycle_range(first_occurrence)) end |
#multiplier ⇒ Object
29 30 31 |
# File 'lib/ri_cal/property_value/recurrence_rule/occurrence_incrementer/frequency_incrementer.rb', line 29 def multiplier 1 end |
#next_cycle(previous_occurrence) ⇒ Object
Advance to the next occurrence, if the result is within the current cycles of all outer incrementers
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/ri_cal/property_value/recurrence_rule/occurrence_incrementer/frequency_incrementer.rb', line 56 def next_cycle(previous_occurrence) @sub_cycle_dtstart = previous_occurrence if current_occurrence candidate = sub_cycle_incrementer.cycle_adjust(step(current_occurrence)) else candidate = step(previous_occurrence) end if outermost? sub_occurrence = sub_cycle_incrementer.first_within_outer_cycle(previous_occurrence, update_cycle_range(candidate)) until sub_occurrence candidate = sub_cycle_incrementer.cycle_adjust(step(candidate)) sub_occurrence = sub_cycle_incrementer.first_within_outer_cycle(previous_occurrence, update_cycle_range(candidate)) end sub_occurrence elsif in_outer_cycle?(candidate) sub_cycle_incrementer.first_within_outer_cycle(previous_occurrence, update_cycle_range(candidate)) else nil end end |
#step(occurrence) ⇒ Object
33 34 35 |
# File 'lib/ri_cal/property_value/recurrence_rule/occurrence_incrementer/frequency_incrementer.rb', line 33 def step(occurrence) occurrence.advance(advance_what => (interval * multiplier)) end |
#sub_cycle_incrementer ⇒ Object
37 38 39 40 41 42 43 |
# File 'lib/ri_cal/property_value/recurrence_rule/occurrence_incrementer/frequency_incrementer.rb', line 37 def sub_cycle_incrementer if @sub_cycle_incrementer.unneeded?(current_occurrence || @previous_occurrence) NullSubCycleIncrementer else super end end |