Class: RiCal::PropertyValue::RecurrenceRule
- Inherits:
-
RiCal::PropertyValue
- Object
- RiCal::PropertyValue
- RiCal::PropertyValue::RecurrenceRule
- Defined in:
- lib/ri_cal/property_value/recurrence_rule.rb,
lib/ri_cal/property_value/recurrence_rule/enumerator.rb,
lib/ri_cal/property_value/recurrence_rule/validations.rb,
lib/ri_cal/property_value/recurrence_rule/numbered_span.rb,
lib/ri_cal/property_value/recurrence_rule/recurring_day.rb,
lib/ri_cal/property_value/recurrence_rule/recurring_year_day.rb,
lib/ri_cal/property_value/recurrence_rule/recurring_month_day.rb,
lib/ri_cal/property_value/recurrence_rule/occurence_incrementer.rb,
lib/ri_cal/property_value/recurrence_rule/initialization_methods.rb,
lib/ri_cal/property_value/recurrence_rule/recurring_numbered_week.rb,
lib/ri_cal/property_value/recurrence_rule/negative_setpos_enumerator.rb,
lib/ri_cal/property_value/recurrence_rule/enumeration_support_methods.rb
Overview
-
©2009 Rick DeNatale
-
All rights reserved. Refer to the file README.txt for the license
RiCal::PropertyValue::RecurrenceRule represents an icalendar Recurrence Rule property value which is defined in rfc 2445 section 4.3.10 pp 40-45
Defined Under Namespace
Modules: EnumerationSupportMethods, InitializationMethods, TimeManipulation, Validations Classes: ByDayIncrementer, ByHourIncrementer, ByMinuteIncrementer, ByMonthIncrementer, ByMonthdayIncrementer, ByNumberedDayIncrementer, BySecondIncrementer, ByWeekNoIncrementer, ByYeardayIncrementer, DailyIncrementer, Enumerator, FrequencyIncrementer, HourlyIncrementer, ListIncrementer, MinutelyIncrementer, MonthlyIncrementer, NegativeSetposEnumerator, NumberedSpan, OccurrenceIncrementer, RecurringDay, RecurringMonthDay, RecurringNumberedWeek, RecurringYearDay, SecondlyIncrementer, WeeklyIncrementer, YearlyIncrementer
Instance Attribute Summary collapse
-
#count ⇒ Object
The integer count value of the receiver, or nil.
-
#until ⇒ Object
The DATE-TIME value of until limit of the receiver, or nil.
Attributes included from InitializationMethods
Attributes inherited from RiCal::PropertyValue
Class Method Summary collapse
-
.convert(parent, value) ⇒ Object
:nodoc:.
Instance Method Summary collapse
-
#bounded? ⇒ Boolean
Predicate to determine if the receiver generates a bounded or infinite set of occurrences.
-
#freq ⇒ Object
return the frequency of the rule which will be a string.
-
#freq=(freq_value) ⇒ Object
- Set the frequency of the recurrence rule freq_value
-
a String which should be in %w[SECONDLY MINUTELY HOURLY DAILY WEEKLY MONTHLY YEARLY].
-
#initialize(parent, value_hash) ⇒ RecurrenceRule
constructor
:nodoc:.
-
#interval ⇒ Object
return the INTERVAL parameter of the recurrence rule This returns an Integer.
-
#interval=(interval_value) ⇒ Object
Set the INTERVAL parameter of the recurrence rule.
-
#to_ical ⇒ Object
Return a string containing the RFC 2445 representation of the recurrence rule.
- #value ⇒ Object
-
#value=(string) ⇒ Object
:nodoc:.
-
#wkst ⇒ Object
return the starting week day for the recurrence rule, which for a valid instance will be one of “SU”, “MO”, “TU”, “WE”, “TH”, “FR”, or “SA”.
-
#wkst=(value) ⇒ Object
Set the starting week day for the recurrence rule, which should be one of “SU”, “MO”, “TU”, “WE”, “TH”, “FR”, or “SA” for the instance to be valid.
-
#wkst_day ⇒ Object
:nodoc:.
Methods included from EnumerationSupportMethods
#adjust_start, #by_rule_list, #enumerator, #exhausted?, #in_same_set?
Methods included from InitializationMethods
#add_byrule_strings_to_options_hash, #add_to_options_hash, #by_list, #byday=, #byhour=, #byminute=, #bymonth=, #bymonthday=, #bysecond=, #bysetpos=, #byweekno=, #byyearday=, #calc_by_day_scope, #init_by_lists, #initialize_from_value_part, #to_options_hash
Methods included from Validations
#errors, #reset_errors, #valid?, #validate, #validate_byday_list, #validate_bymonthday_list, #validate_bysetpos, #validate_byweekno_list, #validate_byyearday_list, #validate_freq, #validate_int_by_list, #validate_interval, #validate_termination, #validate_wkst
Methods inherited from RiCal::PropertyValue
#==, #add_date_times_to, date_or_date_time, #enumerator, #equality_value, #for_parent, from_string, #parms_string, #ruby_value, #to_options_hash, #to_ri_cal_property_value, #to_s, #validate_value, #visible_params
Constructor Details
#initialize(parent, value_hash) ⇒ RecurrenceRule
:nodoc:
15 16 17 18 19 20 |
# File 'lib/ri_cal/property_value/recurrence_rule.rb', line 15 def initialize(parent, value_hash) # :nodoc: @by_list_hash = {} super init_by_lists @by_list_hash = nil end |
Instance Attribute Details
#count ⇒ Object
The integer count value of the receiver, or nil
36 37 38 |
# File 'lib/ri_cal/property_value/recurrence_rule.rb', line 36 def count @count end |
#until ⇒ Object
The DATE-TIME value of until limit of the receiver, or nil
38 39 40 |
# File 'lib/ri_cal/property_value/recurrence_rule.rb', line 38 def until @until end |
Class Method Details
.convert(parent, value) ⇒ Object
:nodoc:
22 23 24 25 26 27 28 29 |
# File 'lib/ri_cal/property_value/recurrence_rule.rb', line 22 def self.convert(parent, value) #:nodoc: if String === value result = new(parent, :value => value) else result = new(parent, value) end result end |
Instance Method Details
#bounded? ⇒ Boolean
Predicate to determine if the receiver generates a bounded or infinite set of occurrences
141 142 143 |
# File 'lib/ri_cal/property_value/recurrence_rule.rb', line 141 def bounded? @count || @until end |
#freq ⇒ Object
return the frequency of the rule which will be a string
60 61 62 |
# File 'lib/ri_cal/property_value/recurrence_rule.rb', line 60 def freq @freq.upcase end |
#freq=(freq_value) ⇒ Object
Set the frequency of the recurrence rule
- freq_value
-
a String which should be in %w[SECONDLY MINUTELY HOURLY DAILY WEEKLY MONTHLY YEARLY]
This method resets the receivers list of errors
54 55 56 57 |
# File 'lib/ri_cal/property_value/recurrence_rule.rb', line 54 def freq=(freq_value) reset_errors @freq = freq_value end |
#interval ⇒ Object
return the INTERVAL parameter of the recurrence rule This returns an Integer
108 109 110 |
# File 'lib/ri_cal/property_value/recurrence_rule.rb', line 108 def interval @interval ||= 1 end |
#interval=(interval_value) ⇒ Object
Set the INTERVAL parameter of the recurrence rule
- interval_value
-
an Integer
This method resets the receivers list of errors
117 118 119 120 |
# File 'lib/ri_cal/property_value/recurrence_rule.rb', line 117 def interval=(interval_value) reset_errors @interval = interval_value end |
#to_ical ⇒ Object
Return a string containing the RFC 2445 representation of the recurrence rule
127 128 129 130 131 132 133 134 135 136 137 138 |
# File 'lib/ri_cal/property_value/recurrence_rule.rb', line 127 def to_ical result = ["FREQ=#{freq}"] result << "INTERVAL=#{interval}" unless interval == 1 result << "COUNT=#{count}" if count result << "UNTIL=#{self.until.value}" if self.until %w{bysecond byminute byhour byday bymonthday byyearday byweekno bymonth bysetpos}.each do |by_part| val = by_list[by_part.to_sym] result << "#{by_part.upcase}=#{[val].flatten.join(',')}" if val end result << "WKST=#{wkst}" unless wkst == "MO" result.join(";") end |
#value ⇒ Object
122 123 124 |
# File 'lib/ri_cal/property_value/recurrence_rule.rb', line 122 def value @value || to_ical end |
#value=(string) ⇒ Object
:nodoc:
40 41 42 43 44 45 46 47 48 |
# File 'lib/ri_cal/property_value/recurrence_rule.rb', line 40 def value=(string) # :nodoc: if string @value = string dup_hash = {} string.split(";").each do |value_part| initialize_from_value_part(value_part, dup_hash) end end end |
#wkst ⇒ Object
return the starting week day for the recurrence rule, which for a valid instance will be one of “SU”, “MO”, “TU”, “WE”, “TH”, “FR”, or “SA”
66 67 68 |
# File 'lib/ri_cal/property_value/recurrence_rule.rb', line 66 def wkst @wkst || 'MO' end |
#wkst=(value) ⇒ Object
Set the starting week day for the recurrence rule, which should be one of “SU”, “MO”, “TU”, “WE”, “TH”, “FR”, or “SA” for the instance to be valid. The parameter is however case-insensitive.
This method resets the receivers list of errors
79 80 81 82 83 |
# File 'lib/ri_cal/property_value/recurrence_rule.rb', line 79 def wkst=(value) reset_errors @wkst = value @wkst_day = nil end |
#wkst_day ⇒ Object
:nodoc:
70 71 72 |
# File 'lib/ri_cal/property_value/recurrence_rule.rb', line 70 def wkst_day # :nodoc: @wkst_day ||= (%w{SU MO TU WE FR SA}.index(wkst) || 1) end |