Module: RiCal::CoreExtensions::String::Conversions

Included in:
String
Defined in:
lib/ri_cal/core_extensions/string/conversions.rb

Overview

  • ©2009 Rick DeNatale

  • All rights reserved. Refer to the file README.txt for the license

Instance Method Summary collapse

Instance Method Details

#to_ri_cal_date_or_date_time_value(timezone_finder = nil) ⇒ Object



23
24
25
26
27
28
29
30
# File 'lib/ri_cal/core_extensions/string/conversions.rb', line 23

def to_ri_cal_date_or_date_time_value(timezone_finder = nil)
  params, value = *Parser.params_and_value(self, :no_leading_semicolon)
  if PropertyValue::DateTime.valid_string?(value) || PropertyValue::Date.valid_string?(value)
    PropertyValue.date_or_date_time(timezone_finder, :params => params, :value => value)
  else
    raise InvalidPropertyValue.new("#{self.inspect} is not a valid rfc 2445 date or date-time")
  end
end

#to_ri_cal_date_time_value(timezone_finder = nil) ⇒ Object

Parse the receiver as an RiCal::PropertyValue::DateTime



13
14
15
16
17
18
19
20
# File 'lib/ri_cal/core_extensions/string/conversions.rb', line 13

def to_ri_cal_date_time_value(timezone_finder = nil)
  params, value = *Parser.params_and_value(self, :no_leading_semicolon)
  if PropertyValue::DateTime.valid_string?(value)
     PropertyValue::DateTime.new(timezone_finder, :params => params, :value => value)
   else
     raise InvalidPropertyValue.new("#{self.inspect} is not a valid rfc 2445 date-time")
   end
end

#to_ri_cal_duration_value(timezone_finder = nil) ⇒ Object

Parse the receiver as an RiCal::PropertyValue::DurationValue



33
34
35
36
37
38
39
40
# File 'lib/ri_cal/core_extensions/string/conversions.rb', line 33

def to_ri_cal_duration_value(timezone_finder = nil)
  params, value = *Parser.params_and_value(self)
  if PropertyValue::Duration.valid_string?(value)
    PropertyValue::Duration.new(timezone_finder, :params => params, :value => value)
  else
    raise InvalidPropertyValue.new("#{self.inspect} is not a valid rfc 2445 duration")
  end
end

#to_ri_cal_occurrence_list_value(timezone_finder = nil) ⇒ Object



42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/ri_cal/core_extensions/string/conversions.rb', line 42

def to_ri_cal_occurrence_list_value(timezone_finder = nil)
  params, value = *Parser.params_and_value(self, :no_leading_semicolon)
  if PropertyValue::DateTime.valid_string?(value)
    PropertyValue::DateTime.new(timezone_finder, :params => params, :value => value)
  elsif PropertyValue::Date.valid_string?(value)
    PropertyValue::Date.new(timezone_finder, :params => params, :value => value)
  elsif PropertyValue::Period.valid_string?(value)
    PropertyValue::Period.new(timezone_finder, :params => params, :value => value)
  else
    raise "Invalid value for occurrence list #{self.inspect}"
  end
end

#to_ri_cal_text_propertyObject

:nodoc:



8
9
10
# File 'lib/ri_cal/core_extensions/string/conversions.rb', line 8

def to_ri_cal_text_property
   PropertyValue::Text.new(nil, :value => self)
end