Class: Icalendar2::TextValue

Inherits:
Value
  • Object
show all
Defined in:
lib/icalendar2/value/text_value.rb

Overview

See tools.ietf.org/html/rfc5545#section-3.3.11 This will escape text passed in, so do not escape it first!

Instance Attribute Summary

Attributes inherited from Value

#value

Instance Method Summary collapse

Methods inherited from Value

get_factory, matches, #to_s, #valid?

Constructor Details

#initialize(value) ⇒ TextValue

Returns a new instance of TextValue.



6
7
8
9
10
11
12
13
14
15
# File 'lib/icalendar2/value/text_value.rb', line 6

def initialize(value)
  replacements = {
    '\\' =>     '\\\\',
    ';' =>      '\;',
    ',' =>      '\,',
    "\r\n" =>   "\n",
    "\r" =>     "\n"
  }
  super(value.respond_to?(:gsub) ? value.gsub(/\\|;|,|\r\n|\r/, replacements) : value)
end