Class: Tilia::VObject::Property::Uri
- Inherits:
-
Text
- Object
- Node
- Tilia::VObject::Property
- Text
- Tilia::VObject::Property::Uri
- Defined in:
- lib/tilia/v_object/property/uri.rb
Overview
URI property.
This object encodes URI values. vCard 2.1 calls these URL.
Constant Summary
Constants inherited from Node
Node::PROFILE_CALDAV, Node::PROFILE_CARDDAV, Node::REPAIR
Instance Attribute Summary collapse
-
#delimiter ⇒ String?
In case this is a multi-value property.
Attributes inherited from Tilia::VObject::Property
Attributes inherited from Node
Instance Method Summary collapse
-
#initialize(*args) ⇒ Uri
constructor
A new instance of Uri.
-
#parameters ⇒ array
Returns an iterable list of children.
-
#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_type ⇒ String
Returns the type of value.
Methods inherited from Text
#json_value, #quoted_printable_value=, #serialize, #validate
Methods inherited from Tilia::VObject::Property
#==, #[], #[]=, #add, #delete, #destroy, #initialize_copy, #json_serialize, #json_value, #json_value=, #key?, #parts, #parts=, #serialize, #to_s, #validate, #xml_serialize, #xml_value=
Methods inherited from Node
#==, #[], #[]=, #delete, #destroy, #each, #json_serialize, #key?, #serialize, #size, #validate, #xml_serialize
Constructor Details
#initialize(*args) ⇒ Uri
Returns a new instance of Uri.
90 91 92 93 |
# File 'lib/tilia/v_object/property/uri.rb', line 90 def initialize(*args) super(*args) @delimiter = nil end |
Instance Attribute Details
#delimiter ⇒ String?
In case this is a multi-value property. This string will be used as a delimiter.
12 13 14 |
# File 'lib/tilia/v_object/property/uri.rb', line 12 def delimiter @delimiter end |
Instance Method Details
#parameters ⇒ array
Returns an iterable list of children.
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/tilia/v_object/property/uri.rb', line 27 def parameters parameters = super if !parameters.key?('VALUE') && ['URL', 'PHOTO'].include?(@name) # If we are encoding a URI value, and this URI value has no # VALUE=URI parameter, we add it anyway. # # This is not required by any spec, but both Apple iCal and Apple # AddressBook (at least in version 10.8) will trip over this if # this is not set, and so it improves compatibility. # # See Issue #227 and #235 parameters['VALUE'] = Parameter.new(@root, 'VALUE', 'URI') end parameters end |
#raw_mime_dir_value ⇒ String
Returns a raw mime-dir representation of the value.
80 81 82 83 84 85 86 87 88 |
# File 'lib/tilia/v_object/property/uri.rb', line 80 def raw_mime_dir_value if @value.is_a?(Array) value = @value[0] else value = @value end value.gsub(',', '\\,') 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.
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/tilia/v_object/property/uri.rb', line 51 def raw_mime_dir_value=(val) # Normally we don't need to do any type of unescaping for these # properties, however.. we've noticed that Google Contacts # specifically escapes the colon (:) with a blackslash. While I have # no clue why they thought that was a good idea, I'm unescaping it # anyway. # # Good thing backslashes are not allowed in urls. Makes it easy to # assume that a backslash is always intended as an escape character. if name == 'URL' new_val = '' val.split(/ (?: (\\\\ (?: \\\\ | : ) ) ) /x).each do |match| case match when '\\:' new_val += ':' else new_val << match end end @value = new_val else @value = val.gsub('\\,', ',') end end |
#value_type ⇒ String
Returns the type of value.
This corresponds to the VALUE= parameter. Every property also has a ‘default’ valueType.
20 21 22 |
# File 'lib/tilia/v_object/property/uri.rb', line 20 def value_type 'URI' end |