Class: Tilia::VObject::Property::FlatText

Inherits:
Text show all
Defined in:
lib/tilia/v_object/property/flat_text.rb

Overview

FlatText property.

This object represents certain TEXT values.

Specifically, this property is used for text values where there is only 1 part. Semi-colons and colons will be de-escaped when deserializing, but if any semi-colons or commas appear without a backslash, we will not assume that they are delimiters.

vCard 2.1 specifically has a whole bunch of properties where this may happen, as it only defines a delimiter for a few properties.

vCard 4.0 states something similar. An unescaped semi-colon may be a delimiter, depending on the property.

Constant Summary

Constants inherited from Node

Node::PROFILE_CALDAV, Node::PROFILE_CARDDAV, Node::REPAIR

Instance Attribute Summary collapse

Attributes inherited from Tilia::VObject::Property

#group, #name, #parameters, #value

Attributes inherited from Node

#iterator, #parent

Instance Method Summary collapse

Methods inherited from Text

#json_value, #raw_mime_dir_value, #raw_mime_dir_value=, #serialize, #validate, #value_type

Methods inherited from Tilia::VObject::Property

#==, #[], #[]=, #add, #delete, #destroy, #initialize_copy, #json_serialize, #json_value, #json_value=, #key?, #parts, #parts=, #raw_mime_dir_value, #raw_mime_dir_value=, #serialize, #to_s, #validate, #value_type, #xml_serialize, #xml_value=

Methods inherited from Node

#==, #[], #[]=, #delete, #destroy, #each, #json_serialize, #key?, #serialize, #size, #validate, #xml_serialize

Constructor Details

#initialize(*args) ⇒ FlatText

Returns a new instance of FlatText.



45
46
47
48
# File 'lib/tilia/v_object/property/flat_text.rb', line 45

def initialize(*args)
  super(*args)
  @delimiter = ','
end

Instance Attribute Details

#delimiterString

Field separator.

Returns:

  • (String)


22
23
24
# File 'lib/tilia/v_object/property/flat_text.rb', line 22

def delimiter
  @delimiter
end

Instance Method Details

#quoted_printable_value=(val) ⇒ void

This method returns an undefined value.

Sets the value as a quoted-printable encoded string.

Overriding this so we’re not splitting on a ; delimiter.

Parameters:

  • val (String)


31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/tilia/v_object/property/flat_text.rb', line 31

def quoted_printable_value=(val)
  val = Mail::Encodings::QuotedPrintable.decode(val)
  val = val.gsub(/\n/, "\r\n").gsub(/\r\r/, "\r")

  # force the correct encoding
  begin
    val.force_encoding(Encoding.find(@parameters['CHARSET'].to_s))
  rescue
    val.force_encoding(Encoding::UTF_8)
  end

  self.value = val
end