Class: Tilia::VObject::Property::ICalendar::Recur
- Inherits:
-
Tilia::VObject::Property
- Object
- Node
- Tilia::VObject::Property
- Tilia::VObject::Property::ICalendar::Recur
- Defined in:
- lib/tilia/v_object/property/i_calendar/recur.rb
Overview
Recur property.
This object represents RECUR properties. These values are just used for RRULE and the now deprecated EXRULE.
The RRULE property may look something like this:
RRULE:FREQ=MONTHLY;BYDAY=1,2,3;BYHOUR=5.
This property exposes this as a key=>value array that is accessible using getParts, and may be set using setParts.
Constant Summary
Constants inherited from Node
Node::PROFILE_CALDAV, Node::PROFILE_CARDDAV, Node::REPAIR
Instance Attribute Summary
Attributes inherited from Tilia::VObject::Property
#delimiter, #group, #name, #parameters
Attributes inherited from Node
Instance Method Summary collapse
-
#json_value ⇒ array
Returns the value, in the format it should be encoded for json.
-
#parts ⇒ array
Returns a multi-valued property.
-
#parts=(parts) ⇒ void
Sets a multi-valued property.
-
#raw_mime_dir_value ⇒ String
Returns a raw mime-dir representation of the value.
-
#raw_mime_dir_value=(val) ⇒ void
Sets a raw value coming from a mimedir (iCalendar/vCard) file.
-
#value ⇒ String
Returns the current value.
-
#value=(value) ⇒ void
Updates the current value.
-
#value_type ⇒ String
Returns the type of value.
Methods inherited from Tilia::VObject::Property
#==, #[], #[]=, #add, #delete, #destroy, #initialize, #initialize_copy, #json_serialize, #json_value=, #key?, #serialize, #to_s, #validate, #xml_serialize, #xml_value=
Methods inherited from Node
#==, #[], #[]=, #delete, #destroy, #each, #initialize, #json_serialize, #key?, #serialize, #size, #validate, #xml_serialize
Constructor Details
This class inherits a constructor from Tilia::VObject::Property
Instance Method Details
#json_value ⇒ array
Returns the value, in the format it should be encoded for json.
This method must always return an array.
117 118 119 120 121 122 123 |
# File 'lib/tilia/v_object/property/i_calendar/recur.rb', line 117 def json_value values = {} parts.each do |k, v| values[k.downcase] = v end [values] end |
#parts ⇒ array
Returns a multi-valued property.
This method always returns an array, if there was only a single value, it will still be wrapped in an array.
80 81 82 |
# File 'lib/tilia/v_object/property/i_calendar/recur.rb', line 80 def parts @value end |
#parts=(parts) ⇒ void
This method returns an undefined value.
Sets a multi-valued property.
70 71 72 |
# File 'lib/tilia/v_object/property/i_calendar/recur.rb', line 70 def parts=(parts) self.value = parts end |
#raw_mime_dir_value ⇒ String
Returns a raw mime-dir representation of the value.
98 99 100 |
# File 'lib/tilia/v_object/property/i_calendar/recur.rb', line 98 def raw_mime_dir_value value end |
#raw_mime_dir_value=(val) ⇒ void
This method returns an undefined value.
Sets a raw value coming from a mimedir (iCalendar/vCard) file.
This has been ‘unfolded’, so only 1 line will be passed. Unescaping is not yet done, but parameters are not included.
91 92 93 |
# File 'lib/tilia/v_object/property/i_calendar/recur.rb', line 91 def raw_mime_dir_value=(val) self.value = val end |
#value ⇒ String
Returns the current value.
This method will always return a singular value. If this was a multi-value object, some decision will be made first on how to represent it as a string.
To get the correct multi-value version, use getParts.
58 59 60 61 62 63 64 |
# File 'lib/tilia/v_object/property/i_calendar/recur.rb', line 58 def value out = [] @value.each do |key, value| out << "#{key}=#{value.is_a?(Array) ? value.join(',') : value}" end out.join(';').upcase end |
#value=(value) ⇒ void
This method returns an undefined value.
Updates the current value.
This may be either a single, or multiple strings in an array.
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/tilia/v_object/property/i_calendar/recur.rb', line 24 def value=(value) if value.is_a?(Hash) new_val = {} value.each do |k, v| if v.is_a?(String) v = v.upcase # The value had multiple sub-values v = v.split(',') if v.index(',') v = v.gsub(/[:\-]/, '') if k == 'until' else v = v.map { |val| val.is_a?(String) ? val.upcase : val } end new_val[k.upcase] = v end @value = new_val elsif value.is_a?(String) @value = self.class.string_to_array(value) else fail ArgumentError, 'You must either pass a string, or a key=>value array' end end |
#value_type ⇒ String
Returns the type of value.
This corresponds to the VALUE= parameter. Every property also has a ‘default’ valueType.
108 109 110 |
# File 'lib/tilia/v_object/property/i_calendar/recur.rb', line 108 def value_type 'RECUR' end |