Class: RiCal::PropertyValue::RecurrenceRule::ByDayIncrementer
Overview
Instance Attribute Summary
#cycle_start, #list, #occurrences, #outer_occurrence
#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
conditional_incrementer, #cycle_adjust, #first_within_outer_cycle, #get_next_occurrences, #next_candidate, #next_cycle, #next_in_list, #occurrences_within
#add_outer_incrementer, #contains_daily_incrementer?, #contains_weeknum_incrementer?, #first_sub_occurrence, #in_outer_cycle?, #next_cycle, #next_time, #outermost?, #short_name, #to_s, #update_cycle_range, #weeknum_incrementer?
#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, list, by_monthday_list, by_yearday_list, parent) ⇒ ByDayIncrementer
Returns a new instance of ByDayIncrementer.
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
|
# File 'lib/ri_cal/property_value/recurrence_rule/occurence_incrementer.rb', line 522
def initialize(rrule, list, by_monthday_list, by_yearday_list, parent)
super(rrule, list, parent)
@monthday_filters = by_monthday_list
@yearday_filters = by_yearday_list
@by_day_scope = rrule.by_day_scope
case rrule.by_day_scope
when :yearly
@cycle_advance_proc = lambda {|date_time| first_day_of_year(advance_year(date_time))}
@current_proc = lambda {|date_time| same_year?(current, date_time)}
@first_day_proc = lambda {|date_time| first_day_of_year(date_time)}
when :monthly
@cycle_advance_proc = lambda {|date_time| first_day_of_month(advance_month(date_time))}
@current_proc = lambda {|date_time| same_month?(current, date_time)}
@first_day_proc = lambda {|date_time| first_day_of_month(date_time)}
when :weekly
@cycle_advance_proc = lambda {|date_time| first_day_of_week(rrule.wkst_day, advance_week(date_time))}
@current_proc = lambda {|date_time| same_week?(rrule.wkst_day, current, date_time)}
@first_day_proc = lambda {|date_time| first_day_of_week(rrule.wkst_day, date_time)}
else
raise "Invalid recurrence rule, byday needs to be scoped by month, week or year"
end
end
|
Class Method Details
.for_rrule(rrule) ⇒ Object
546
547
548
549
550
551
552
553
554
|
# File 'lib/ri_cal/property_value/recurrence_rule/occurence_incrementer.rb', line 546
def self.for_rrule(rrule)
list = rrule.by_rule_list(:byday)
if list
sub_cycle_incrementer = DailyIncrementer.for_rrule(rrule)
new(rrule, list, rrule.by_rule_list(:bymonthday), rrule.by_rule_list(:byyearday), sub_cycle_incrementer)
else
ByYeardayIncrementer.for_rrule(rrule)
end
end
|
Instance Method Details
#advance_cycle(date_time) ⇒ Object
584
585
586
|
# File 'lib/ri_cal/property_value/recurrence_rule/occurence_incrementer.rb', line 584
def advance_cycle(date_time)
@cycle_advance_proc.call(date_time)
end
|
#candidate_acceptible?(candidate) ⇒ Boolean
576
577
578
|
# File 'lib/ri_cal/property_value/recurrence_rule/occurence_incrementer.rb', line 576
def candidate_acceptible?(candidate)
list.any? {|recurring_day| recurring_day.include?(candidate)}
end
|
#daily_incrementer? ⇒ Boolean
556
557
558
|
# File 'lib/ri_cal/property_value/recurrence_rule/occurence_incrementer.rb', line 556
def daily_incrementer?
true
end
|
#end_of_occurrence(date_time) ⇒ Object
588
589
590
|
# File 'lib/ri_cal/property_value/recurrence_rule/occurence_incrementer.rb', line 588
def end_of_occurrence(date_time)
date_time.end_of_day
end
|
#occurrences_for(date_time) ⇒ Object
564
565
566
567
568
569
570
571
572
573
574
|
# File 'lib/ri_cal/property_value/recurrence_rule/occurence_incrementer.rb', line 564
def occurrences_for(date_time)
first_day = start_of_cycle(date_time)
result = list.map {|recurring_day| recurring_day.matches_for(first_day)}.flatten.uniq.sort
if @monthday_filters
result = result.select {|occurrence| @monthday_filters.any? {|recurring_day| recurring_day.include?(occurrence)}}
end
if @yearday_filters
result = result.select {|occurrence| @yearday_filters.any? {|recurring_day| recurring_day.include?(occurrence)}}
end
result
end
|
#start_of_cycle(date_time) ⇒ Object
560
561
562
|
# File 'lib/ri_cal/property_value/recurrence_rule/occurence_incrementer.rb', line 560
def start_of_cycle(date_time)
@first_day_proc.call(date_time)
end
|
#varying_time_attribute ⇒ Object
580
581
582
|
# File 'lib/ri_cal/property_value/recurrence_rule/occurence_incrementer.rb', line 580
def varying_time_attribute
:day
end
|