Class: RiCal::PropertyValue::Period
- Inherits:
-
RiCal::PropertyValue
- Object
- RiCal::PropertyValue
- RiCal::PropertyValue::Period
- Defined in:
- lib/ri_cal/property_value/period.rb
Overview
RiCal::PropertyValue::CalAddress represents an icalendar Period property value which is defined in rfc 2445 section 4.3.9 p 39
Known bugs. This doesn’t properly work when dtstart, dtend or duration are changed independently
Instance Attribute Summary collapse
-
#dtend ⇒ Object
The DATE-TIME on which the period ends.
-
#dtstart ⇒ Object
The DATE-TIME on which the period starts.
-
#duration ⇒ Object
The DURATION of the period.
Attributes inherited from RiCal::PropertyValue
#params, #timezone_finder, #value
Class Method Summary collapse
-
.convert(parent, ruby_object) ⇒ Object
:nodoc:.
-
.valid_string?(string) ⇒ Boolean
:nodoc:.
Instance Method Summary collapse
-
#add_date_times_to(required_timezones) ⇒ Object
:nodoc:.
-
#for_parent(parent) ⇒ Object
:nodoc:.
-
#occurrence_period(default_duration) ⇒ Object
:nodoc:.
- #ruby_value ⇒ Object
-
#to_ri_cal_period_value ⇒ Object
return the receiver.
-
#tzid ⇒ Object
:nodoc:.
-
#tzid=(val) ⇒ Object
Nop to allow occurrence list to try to set it.
-
#value=(string) ⇒ Object
:nodoc:.
Methods inherited from RiCal::PropertyValue
#==, date_or_date_time, date_or_date_time_or_period, #default_tzid, #enumerator, #equality_value, #find_timezone, if_valid_string, #initialize, #parms_string, #to_options_hash, #to_ri_cal_property_value, #to_s, #tz_info_source?, #validate_value, #visible_params
Constructor Details
This class inherits a constructor from RiCal::PropertyValue
Instance Attribute Details
#dtend ⇒ Object
The DATE-TIME on which the period ends
13 14 15 |
# File 'lib/ri_cal/property_value/period.rb', line 13 def dtend @dtend end |
#dtstart ⇒ Object
The DATE-TIME on which the period starts
11 12 13 |
# File 'lib/ri_cal/property_value/period.rb', line 11 def dtstart @dtstart end |
#duration ⇒ Object
The DURATION of the period
15 16 17 |
# File 'lib/ri_cal/property_value/period.rb', line 15 def duration @duration end |
Class Method Details
.convert(parent, ruby_object) ⇒ Object
:nodoc:
65 66 67 |
# File 'lib/ri_cal/property_value/period.rb', line 65 def self.convert(parent, ruby_object) # :nodoc: ruby_object.to_ri_cal_period_value.for_parent(parent) end |
.valid_string?(string) ⇒ Boolean
:nodoc:
34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/ri_cal/property_value/period.rb', line 34 def self.valid_string?(string) # :nodoc: return false unless string.include?("/") starter, terminator = *string.split("/") return false unless PropertyValue::DateTime.valid_string?(starter) if /P/ =~ terminator return false unless PropertyValue::Duration.valid_string?(terminator) else return false unless PropertyValue::DateTime.valid_string?(terminator) end true end |
Instance Method Details
#add_date_times_to(required_timezones) ⇒ Object
:nodoc:
78 79 80 81 |
# File 'lib/ri_cal/property_value/period.rb', line 78 def add_date_times_to(required_timezones) #:nodoc: dtstart.add_date_times_to(required_timezones) dtend.add_date_times_to(required_timezones) end |
#for_parent(parent) ⇒ Object
:nodoc:
54 55 56 57 58 59 60 61 62 63 |
# File 'lib/ri_cal/property_value/period.rb', line 54 def for_parent(parent) #:nodoc: if timezone_finder.nil @timezone_finder = parent self elsif timezone_finder == parent self else Period.new(parent, :value => value) end end |
#occurrence_period(default_duration) ⇒ Object
:nodoc:
74 75 76 |
# File 'lib/ri_cal/property_value/period.rb', line 74 def occurrence_period(default_duration) #:nodoc: RiCal::OccurrencePeriod.new(self, (default_duration ? self + default_duration : nil)) end |
#ruby_value ⇒ Object
30 31 32 |
# File 'lib/ri_cal/property_value/period.rb', line 30 def ruby_value self end |
#to_ri_cal_period_value ⇒ Object
return the receiver
70 71 72 |
# File 'lib/ri_cal/property_value/period.rb', line 70 def to_ri_cal_period_value self end |
#tzid ⇒ Object
:nodoc:
50 51 52 |
# File 'lib/ri_cal/property_value/period.rb', line 50 def tzid #:nodoc: nil end |
#tzid=(val) ⇒ Object
Nop to allow occurrence list to try to set it
47 48 |
# File 'lib/ri_cal/property_value/period.rb', line 47 def tzid=(val)#:nodoc: end |
#value=(string) ⇒ Object
:nodoc:
17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/ri_cal/property_value/period.rb', line 17 def value=(string) # :nodoc: starter, terminator = *string.split("/") self.dtstart = PropertyValue::DateTime.new(self, :value => starter) if /P/ =~ terminator self.duration = PropertyValue::Duration.new(self, :value => terminator) self.dtend = dtstart + duration else self.dtend = PropertyValue::DateTime.new(self, :value => terminator) self.duration = PropertyValue::Duration.from_datetimes(self, dtstart.to_datetime, dtend.to_datetime) end @value = string end |