Class: RiCal::PropertyValue::RecurrenceRule::FrequencyIncrementer
- Inherits:
-
OccurrenceIncrementer
- Object
- OccurrenceIncrementer
- RiCal::PropertyValue::RecurrenceRule::FrequencyIncrementer
- Defined in:
- lib/ri_cal/property_value/recurrence_rule/occurence_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 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
- #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
Methods inherited from OccurrenceIncrementer
#add_outer_incrementer, #contains_daily_incrementer?, #contains_weeknum_incrementer?, #daily_incrementer?, #first_sub_occurrence, #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.
263 264 265 266 |
# File 'lib/ri_cal/property_value/recurrence_rule/occurence_incrementer.rb', line 263 def initialize(rrule, sub_cycle_incrementer) super(rrule, sub_cycle_incrementer) self.interval = rrule.interval end |
Instance Attribute Details
#interval ⇒ Object
:nodoc:
259 260 261 |
# File 'lib/ri_cal/property_value/recurrence_rule/occurence_incrementer.rb', line 259 def interval @interval end |
#outer_occurrence ⇒ Object
:nodoc:
259 260 261 |
# File 'lib/ri_cal/property_value/recurrence_rule/occurence_incrementer.rb', line 259 def outer_occurrence @outer_occurrence end |
#skip_increment ⇒ Object
:nodoc:
259 260 261 |
# File 'lib/ri_cal/property_value/recurrence_rule/occurence_incrementer.rb', line 259 def skip_increment @skip_increment end |
Class Method Details
.conditional_incrementer(rrule, freq_str, sub_cycle_class) ⇒ Object
268 269 270 271 272 273 274 275 |
# File 'lib/ri_cal/property_value/recurrence_rule/occurence_incrementer.rb', line 268 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
285 286 287 288 289 290 291 292 293 |
# File 'lib/ri_cal/property_value/recurrence_rule/occurence_incrementer.rb', line 285 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
277 278 279 |
# File 'lib/ri_cal/property_value/recurrence_rule/occurence_incrementer.rb', line 277 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
296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 |
# File 'lib/ri_cal/property_value/recurrence_rule/occurence_incrementer.rb', line 296 def next_cycle(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
281 282 283 |
# File 'lib/ri_cal/property_value/recurrence_rule/occurence_incrementer.rb', line 281 def step(occurrence) occurrence.advance(advance_what => (interval * multiplier)) end |