Class: RiCal::PropertyValue
- Defined in:
- lib/ri_cal/property_value.rb,
lib/ri_cal/property_value/geo.rb,
lib/ri_cal/property_value/uri.rb,
lib/ri_cal/property_value/date.rb,
lib/ri_cal/property_value/text.rb,
lib/ri_cal/property_value/array.rb,
lib/ri_cal/property_value/period.rb,
lib/ri_cal/property_value/integer.rb,
lib/ri_cal/property_value/duration.rb,
lib/ri_cal/property_value/date_time.rb,
lib/ri_cal/property_value/utc_offset.rb,
lib/ri_cal/property_value/cal_address.rb,
lib/ri_cal/property_value/zulu_date_time.rb,
lib/ri_cal/property_value/occurrence_list.rb,
lib/ri_cal/property_value/recurrence_rule.rb,
lib/ri_cal/property_value/date_time/time_machine.rb,
lib/ri_cal/property_value/date_time/additive_methods.rb,
lib/ri_cal/property_value/date_time/timezone_support.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/time_manipulation.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/initialization_methods.rb,
lib/ri_cal/property_value/recurrence_rule/occurrence_incrementer.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,
lib/ri_cal/property_value/recurrence_rule/occurrence_incrementer/list_incrementer.rb,
lib/ri_cal/property_value/recurrence_rule/occurrence_incrementer/daily_incrementer.rb,
lib/ri_cal/property_value/recurrence_rule/occurrence_incrementer/by_day_incrementer.rb,
lib/ri_cal/property_value/recurrence_rule/occurrence_incrementer/hourly_incrementer.rb,
lib/ri_cal/property_value/recurrence_rule/occurrence_incrementer/weekly_incrementer.rb,
lib/ri_cal/property_value/recurrence_rule/occurrence_incrementer/yearly_incrementer.rb,
lib/ri_cal/property_value/recurrence_rule/occurrence_incrementer/by_hour_incrementer.rb,
lib/ri_cal/property_value/recurrence_rule/occurrence_incrementer/monthly_incrementer.rb,
lib/ri_cal/property_value/recurrence_rule/occurrence_incrementer/by_month_incrementer.rb,
lib/ri_cal/property_value/recurrence_rule/occurrence_incrementer/minutely_incrementer.rb,
lib/ri_cal/property_value/recurrence_rule/occurrence_incrementer/secondly_incrementer.rb,
lib/ri_cal/property_value/recurrence_rule/occurrence_incrementer/by_minute_incrementer.rb,
lib/ri_cal/property_value/recurrence_rule/occurrence_incrementer/by_second_incrementer.rb,
lib/ri_cal/property_value/recurrence_rule/occurrence_incrementer/by_weekno_incrementer.rb,
lib/ri_cal/property_value/recurrence_rule/occurrence_incrementer/frequency_incrementer.rb,
lib/ri_cal/property_value/recurrence_rule/occurrence_incrementer/by_yearday_incrementer.rb,
lib/ri_cal/property_value/recurrence_rule/occurrence_incrementer/by_monthday_incrementer.rb,
lib/ri_cal/property_value/recurrence_rule/occurrence_incrementer/null_sub_cycle_incrementer.rb,
lib/ri_cal/property_value/recurrence_rule/occurrence_incrementer/by_numbered_day_incrementer.rb
Overview
PropertyValue provides common implementation of various RFC 2445 property value types
Direct Known Subclasses
Array, CalAddress, Date, DateTime, Duration, Geo, Integer, Period, RecurrenceRule, Text, Uri, UtcOffset
Defined Under Namespace
Classes: Array, CalAddress, Date, DateTime, Duration, Geo, Integer, OccurrenceList, Period, RecurrenceRule, Text, Uri, UtcOffset, ZuluDateTime
Instance Attribute Summary collapse
-
#params ⇒ Object
return a hash containing the parameters and values, if any.
-
#timezone_finder ⇒ Object
readonly
:nodoc:.
-
#value ⇒ Object
Return the string value.
Class Method Summary collapse
-
.convert(timezone_finder, value) ⇒ Object
def self.from_string(string) # :nodoc: new(nil, :value => string) end.
-
.date_or_date_time(timezone_finder, separated_line) ⇒ Object
:nodoc:.
-
.date_or_date_time_or_period(timezone_finder, separated_line) ⇒ Object
:nodoc:.
-
.if_valid_string(timezone_finder, string) ⇒ Object
:nodoc:.
Instance Method Summary collapse
-
#==(o) ⇒ Object
Determine if another object is equivalent to the receiver.
-
#add_date_times_to(required_timezones) ⇒ Object
:nodoc:.
-
#default_tzid ⇒ Object
:nodoc:.
-
#enumerator(component) ⇒ Object
Return an enumerator which can produce the elements of the occurrence list.
-
#equality_value ⇒ Object
:nodoc:.
-
#find_timezone(timezone_identifier) ⇒ Object
:nodoc:.
-
#for_parent(parent) ⇒ Object
:nodoc:.
-
#initialize(timezone_finder, options = {}) ⇒ PropertyValue
constructor
:nodoc:.
-
#parms_string ⇒ Object
:nodoc:.
-
#ruby_value ⇒ Object
return the ruby value.
-
#to_options_hash ⇒ Object
:nodoc:.
-
#to_ri_cal_property_value ⇒ Object
:nodoc:.
-
#to_s ⇒ Object
Return a string representing the receiver in RFC 2445 format.
-
#tz_info_source? ⇒ Boolean
:nodoc:.
-
#validate_value(options) ⇒ Object
:nodoc:.
-
#visible_params ⇒ Object
:nodoc:.
Constructor Details
#initialize(timezone_finder, options = {}) ⇒ PropertyValue
:nodoc:
22 23 24 25 26 27 28 29 30 31 |
# File 'lib/ri_cal/property_value.rb', line 22 def initialize(timezone_finder, ={}) # :nodoc: @timezone_finder = timezone_finder validate_value() ({:params => {}}).merge().each do |attribute, val| unless attribute == :name setter = :"#{attribute.to_s.downcase}=" send(setter, val) end end end |
Instance Attribute Details
#params ⇒ Object
return a hash containing the parameters and values, if any
47 48 49 |
# File 'lib/ri_cal/property_value.rb', line 47 def params @params ||= {} end |
#timezone_finder ⇒ Object (readonly)
:nodoc:
21 22 23 |
# File 'lib/ri_cal/property_value.rb', line 21 def timezone_finder @timezone_finder end |
#value ⇒ Object
Return the string value
98 99 100 |
# File 'lib/ri_cal/property_value.rb', line 98 def value @value end |
Class Method Details
.convert(timezone_finder, value) ⇒ Object
def self.from_string(string) # :nodoc:
new(nil, :value => string)
end
84 85 86 |
# File 'lib/ri_cal/property_value.rb', line 84 def self.convert(timezone_finder, value) #:nodoc: new(timezone_finder, :value => value) end |
.date_or_date_time(timezone_finder, separated_line) ⇒ Object
:nodoc:
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/ri_cal/property_value.rb', line 56 def self.date_or_date_time(timezone_finder, separated_line) # :nodoc: match = separated_line[:value].match(/(\d\d\d\d)(\d\d)(\d\d)((T?)((\d\d)(\d\d)(\d\d))(Z?))?/) raise Exception.new("Invalid date") unless match if match[5] == "T" # date-time time = Time.utc(match[1].to_i, match[2].to_i, match[3].to_i, match[7].to_i, match[8].to_i, match[9].to_i) parms = (separated_line[:params] ||{}).dup if match[10] == "Z" raise Exception.new("Invalid time, cannot combine Zulu with timezone reference") if parms[:tzid] parms['TZID'] = "UTC" end PropertyValue::DateTime.new(timezone_finder, separated_line.merge(:params => parms)) else PropertyValue::Date.new(timezone_finder, separated_line) end end |
.date_or_date_time_or_period(timezone_finder, separated_line) ⇒ Object
:nodoc:
72 73 74 75 76 77 78 |
# File 'lib/ri_cal/property_value.rb', line 72 def self.date_or_date_time_or_period(timezone_finder, separated_line) #:nodoc: if separated_line[:value].include?("/") PropertyValue::Period.new(timezone_finder, separated_line) else date_or_date_time(timezone_finder, separated_line) end end |
.if_valid_string(timezone_finder, string) ⇒ Object
:nodoc:
33 34 35 36 37 38 39 |
# File 'lib/ri_cal/property_value.rb', line 33 def self.if_valid_string(timezone_finder, string) #:nodoc: if valid_string?(string) new(timezone_finder, :value => string) else nil end end |
Instance Method Details
#==(o) ⇒ Object
Determine if another object is equivalent to the receiver.
89 90 91 92 93 94 95 |
# File 'lib/ri_cal/property_value.rb', line 89 def ==(o) if o.class == self.class equality_value == o.equality_value else super end end |
#add_date_times_to(required_timezones) ⇒ Object
:nodoc:
133 134 135 136 137 138 139 |
# File 'lib/ri_cal/property_value/occurrence_list.rb', line 133 def add_date_times_to(required_timezones) #:nodoc: if @elements @elements.each do | occurrence | occurrence.add_date_times_to(required_timezones) end end end |
#default_tzid ⇒ Object
:nodoc:
141 142 143 144 145 146 147 |
# File 'lib/ri_cal/property_value.rb', line 141 def default_tzid #:nodoc: if timezone_finder timezone_finder.default_tzid else PropertyValue::DateTime.default_tzid end end |
#enumerator(component) ⇒ Object
Return an enumerator which can produce the elements of the occurrence list
129 130 131 |
# File 'lib/ri_cal/property_value/occurrence_list.rb', line 129 def enumerator(component) # :nodoc: OccurrenceList::Enumerator.new(@elements, component) end |
#equality_value ⇒ Object
:nodoc:
102 103 104 |
# File 'lib/ri_cal/property_value.rb', line 102 def equality_value #:nodoc: value end |
#find_timezone(timezone_identifier) ⇒ Object
:nodoc:
133 134 135 136 137 138 139 |
# File 'lib/ri_cal/property_value.rb', line 133 def find_timezone(timezone_identifier) #:nodoc: if timezone_finder timezone_finder.find_timezone(timezone_identifier) else raise "Unable to find timezone with tzid #{timezone_identifier}" end end |
#for_parent(parent) ⇒ Object
:nodoc:
117 118 119 120 121 122 123 124 125 126 |
# File 'lib/ri_cal/property_value/occurrence_list.rb', line 117 def for_parent(parent) #:nodoc: if timezone_finder.nil? @timezone_finder = parent self elsif timezone_finder == parent self else OccurrenceList.new(parent, :value => value) end end |
#parms_string ⇒ Object
:nodoc:
110 111 112 113 114 115 116 117 |
# File 'lib/ri_cal/property_value.rb', line 110 def parms_string #:nodoc: if (vp = visible_params) && !vp.empty? # We only sort for testability reasons vp.keys.sort.map {|key| ";#{key}=#{vp[key]}"}.join else "" end end |
#ruby_value ⇒ Object
return the ruby value
125 126 127 |
# File 'lib/ri_cal/property_value.rb', line 125 def ruby_value self.value end |
#to_options_hash ⇒ Object
:nodoc:
51 52 53 54 |
# File 'lib/ri_cal/property_value.rb', line 51 def #:nodoc: = {:value => value} [:params] = params unless params.empty? end |
#to_ri_cal_property_value ⇒ Object
:nodoc:
129 130 131 |
# File 'lib/ri_cal/property_value.rb', line 129 def to_ri_cal_property_value #:nodoc: self end |
#to_s ⇒ Object
Return a string representing the receiver in RFC 2445 format
120 121 122 |
# File 'lib/ri_cal/property_value.rb', line 120 def to_s #:nodoc: "#{parms_string}:#{value}" end |
#tz_info_source? ⇒ Boolean
:nodoc:
149 150 151 152 153 154 155 |
# File 'lib/ri_cal/property_value.rb', line 149 def tz_info_source? #:nodoc: if timezone_finder timezone_finder.tz_info_source? else true end end |
#validate_value(options) ⇒ Object
:nodoc:
41 42 43 44 |
# File 'lib/ri_cal/property_value.rb', line 41 def validate_value() #:nodoc: val = [:value] raise "Invalid property value #{val.inspect}" if val.kind_of?(String) && /^;/.match(val) end |
#visible_params ⇒ Object
:nodoc:
106 107 108 |
# File 'lib/ri_cal/property_value.rb', line 106 def visible_params # :nodoc: params end |