Class: Vcard::V4_0::PropertyValue::Text
Instance Attribute Summary
#errors, #norm, #type, #value
Class Method Summary
collapse
Instance Method Summary
collapse
#<=>, #name, #to_norm
Constructor Details
#initialize(val) ⇒ Text
Returns a new instance of Text.
30
31
32
33
|
# File 'lib/vobject/vcard/v4_0/propertyvalue.rb', line 30
def initialize(val)
self.value = val
self.type = "text"
end
|
Class Method Details
.escape(x) ⇒ Object
8
9
10
11
|
# File 'lib/vobject/vcard/v4_0/propertyvalue.rb', line 8
def escape(x)
x.tr("\\", "\u007f").gsub(/\n/, "\\n").gsub(/,/, "\\,").gsub(/\u007f/, "\\\\")
end
|
.escape_component(x) ⇒ Object
13
14
15
16
|
# File 'lib/vobject/vcard/v4_0/propertyvalue.rb', line 13
def escape_component(x)
x.tr("\\", "\u007f").gsub(/\n/, "\\n").gsub(/,/, "\\,").gsub(/;/, "\\;").gsub(/\u007f/, "\\\\")
end
|
.listencode(x) ⇒ Object
18
19
20
21
22
23
24
25
26
27
|
# File 'lib/vobject/vcard/v4_0/propertyvalue.rb', line 18
def listencode(x)
ret = if x.is_a?(Array)
x.map { |m| Text.escape_component m }.join(",")
elsif x.nil? || x.empty?
""
else
Text.escape_component x
end
ret
end
|
Instance Method Details
#to_hash ⇒ Object
39
40
41
|
# File 'lib/vobject/vcard/v4_0/propertyvalue.rb', line 39
def to_hash
value
end
|
#to_s ⇒ Object
35
36
37
|
# File 'lib/vobject/vcard/v4_0/propertyvalue.rb', line 35
def to_s
Text.escape value
end
|