Class: Vobject::Vcalendar::PropertyValue::Text

Inherits:
PropertyValue show all
Defined in:
lib/vobject/vcalendar/propertyvalue.rb

Instance Attribute Summary

Attributes inherited from PropertyValue

#errors, #norm, #type, #value

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from PropertyValue

#<=>, #name, #to_norm

Constructor Details

#initialize(val) ⇒ Text

Returns a new instance of Text.



16
17
18
19
# File 'lib/vobject/vcalendar/propertyvalue.rb', line 16

def initialize(val)
  self.value = val
  self.type = "text"
end

Class Method Details

.escape(x) ⇒ Object



9
10
11
12
13
# File 'lib/vobject/vcalendar/propertyvalue.rb', line 9

def escape(x)
  # temporarily escape \\ as \u007f, which is banned from text
  x.tr("\\", "\u007f").gsub(/\n/, "\\n").gsub(/,/, "\\,").
    gsub(/;/, "\\;").gsub(/\u007f/, "\\\\\\\\")
end

Instance Method Details

#to_hashObject



25
26
27
# File 'lib/vobject/vcalendar/propertyvalue.rb', line 25

def to_hash
  value
end

#to_sObject



21
22
23
# File 'lib/vobject/vcalendar/propertyvalue.rb', line 21

def to_s
  Text.escape value
end