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
-
#camelize ⇒ Object
Convert the receiver to camelized form This method duplicates the method provided by ActiveSupport, and will only be defined by the RiCal gem if it is not already defined.
- #to_ri_cal_date_or_date_time_value(timezone_finder = nil) ⇒ Object
-
#to_ri_cal_date_time_value(timezone_finder = nil) ⇒ Object
Parse the receiver as an RiCal::PropertyValue::DateTime.
-
#to_ri_cal_duration_value(timezone_finder = nil) ⇒ Object
Parse the receiver as an RiCal::PropertyValue::DurationValue.
- #to_ri_cal_occurrence_list_value(timezone_finder = nil) ⇒ Object
Instance Method Details
#camelize ⇒ Object
Convert the receiver to camelized form This method duplicates the method provided by ActiveSupport, and will only be defined by the RiCal gem if it is not already defined.
56 57 58 |
# File 'lib/ri_cal/core_extensions/string/conversions.rb', line 56 def camelize self.gsub(/\/(.?)/) { "::#{$1.upcase}" }.gsub(/(?:^|_)(.)/) { $1.upcase } end |
#to_ri_cal_date_or_date_time_value(timezone_finder = nil) ⇒ Object
19 20 21 22 23 24 25 26 |
# File 'lib/ri_cal/core_extensions/string/conversions.rb', line 19 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
9 10 11 12 13 14 15 16 |
# File 'lib/ri_cal/core_extensions/string/conversions.rb', line 9 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
29 30 31 32 33 34 35 36 |
# File 'lib/ri_cal/core_extensions/string/conversions.rb', line 29 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
38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/ri_cal/core_extensions/string/conversions.rb', line 38 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 |