Class: RiCal::PropertyValue::RecurrenceRule::OccurrenceIncrementer::ByWeekNoIncrementer
- Inherits:
-
ListIncrementer
show all
- Defined in:
- lib/ri_cal/property_value/recurrence_rule/occurrence_incrementer/by_weekno_incrementer.rb
Overview
Instance Attribute Summary collapse
#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, #get_next_occurrences, #next_candidate, #next_cycle, #next_in_list, #occurrences_within
#add_outer_incrementer, #contains_daily_incrementer?, #contains_weeknum_incrementer?, #daily_incrementer?, #first_sub_occurrence, from_rrule, #in_outer_cycle?, #next_cycle, #next_time, #outermost?, #short_name, #to_s, #update_cycle_range
#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, sub_cycle_incrementer) ⇒ ByWeekNoIncrementer
include WeeklyBydayMethods
9
10
11
12
|
# File 'lib/ri_cal/property_value/recurrence_rule/occurrence_incrementer/by_weekno_incrementer.rb', line 9
def initialize(rrule, list, sub_cycle_incrementer)
@wkst = rrule.wkst_day
super(rrule, list, sub_cycle_incrementer)
end
|
Instance Attribute Details
Returns the value of attribute wkst.
6
7
8
|
# File 'lib/ri_cal/property_value/recurrence_rule/occurrence_incrementer/by_weekno_incrementer.rb', line 6
def wkst
@wkst
end
|
Class Method Details
.for_rrule(rrule) ⇒ Object
14
15
16
|
# File 'lib/ri_cal/property_value/recurrence_rule/occurrence_incrementer/by_weekno_incrementer.rb', line 14
def self.for_rrule(rrule)
conditional_incrementer(rrule, :byweekno, WeeklyIncrementer)
end
|
Instance Method Details
#advance_cycle(date_time) ⇒ Object
56
57
58
|
# File 'lib/ri_cal/property_value/recurrence_rule/occurrence_incrementer/by_weekno_incrementer.rb', line 56
def advance_cycle(date_time)
date_time.at_start_of_next_iso_year(wkst)
end
|
#candidate_acceptable?(candidate) ⇒ Boolean
52
53
54
|
# File 'lib/ri_cal/property_value/recurrence_rule/occurrence_incrementer/by_weekno_incrementer.rb', line 52
def candidate_acceptable?(candidate)
list.include?(candidate.iso_week_num(wkst))
end
|
#end_of_occurrence(date_time) ⇒ Object
60
61
62
|
# File 'lib/ri_cal/property_value/recurrence_rule/occurrence_incrementer/by_weekno_incrementer.rb', line 60
def end_of_occurrence(date_time)
date_time.end_of_week_with_wkst(wkst)
end
|
#first_within_outer_cycle(previous_occurrence, outer_range) ⇒ Object
26
27
28
29
30
|
# File 'lib/ri_cal/property_value/recurrence_rule/occurrence_incrementer/by_weekno_incrementer.rb', line 26
def first_within_outer_cycle(previous_occurrence, outer_range)
new_range_start = outer_range.first
new_range_end = new_range_start.end_of_iso_year(wkst)
super(previous_occurrence, outer_range.first..new_range_end)
end
|
#occurrences_for(date_time) ⇒ Object
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
# File 'lib/ri_cal/property_value/recurrence_rule/occurrence_incrementer/by_weekno_incrementer.rb', line 37
def occurrences_for(date_time)
iso_year, year_start = *date_time.iso_year_and_week_one_start(wkst)
week_one_occurrence = date_time.change(
:year => year_start.year,
:month => year_start.month,
:day => year_start.day
)
weeks_in_year_plus_one = week_one_occurrence.iso_weeks_in_year(wkst)
weeks = list.map {|recurring_weeknum|
wk_num = recurring_weeknum.ordinal
(wk_num > 0) ? wk_num : weeks_in_year_plus_one + wk_num
}.uniq.sort
weeks.map {|wk_num| week_one_occurrence.advance(:days => (wk_num - 1) * 7)}
end
|
#start_of_cycle(date_time) ⇒ Object
32
33
34
35
|
# File 'lib/ri_cal/property_value/recurrence_rule/occurrence_incrementer/by_weekno_incrementer.rb', line 32
def start_of_cycle(date_time)
result = date_time.at_start_of_iso_year(wkst)
result
end
|
#unneeded?(candidate) ⇒ Boolean
22
23
24
|
# File 'lib/ri_cal/property_value/recurrence_rule/occurrence_incrementer/by_weekno_incrementer.rb', line 22
def unneeded?(candidate)
false
end
|
#weeknum_incrementer? ⇒ Boolean
18
19
20
|
# File 'lib/ri_cal/property_value/recurrence_rule/occurrence_incrementer/by_weekno_incrementer.rb', line 18
def weeknum_incrementer?
true
end
|