Class: Icalendar::Values::Text
- Inherits:
-
Icalendar::Value
- Object
- SimpleDelegator
- Icalendar::Value
- Icalendar::Values::Text
- Defined in:
- lib/icalendar/values/text.rb
Constant Summary collapse
- UNESCAPE_GSUB_REGEX =
/\\([\\,;nN])/.freeze
- VALUE_ICAL_CARRIAGE_RETURN_GSUB_REGEX =
/\r?\n/.freeze
Constants inherited from Icalendar::Value
Icalendar::Value::VALUE_TYPE_GSUB_REGEX_1, Icalendar::Value::VALUE_TYPE_GSUB_REGEX_2
Instance Attribute Summary
Attributes inherited from Icalendar::Value
Instance Method Summary collapse
-
#initialize(value, *args) ⇒ Text
constructor
A new instance of Text.
- #value_ical ⇒ Object
Methods inherited from Icalendar::Value
#==, #ical_param, #params_ical, #to_ical, #value, value_type, #value_type
Constructor Details
#initialize(value, *args) ⇒ Text
Returns a new instance of Text.
8 9 10 11 12 |
# File 'lib/icalendar/values/text.rb', line 8 def initialize(value, *args) # One left-to-right pass keeps unescape the exact inverse of value_ical; \n and \N are newline. value = value.gsub(UNESCAPE_GSUB_REGEX) { |_| %w[n N].include?($1) ? "\n" : $1 } super value, *args end |
Instance Method Details
#value_ical ⇒ Object
16 17 18 19 20 21 22 23 |
# File 'lib/icalendar/values/text.rb', line 16 def value_ical value.dup.tap do |v| v.gsub!('\\') { '\\\\' } v.gsub!(';', '\;') v.gsub!(',', '\,') v.gsub!(VALUE_ICAL_CARRIAGE_RETURN_GSUB_REGEX, '\n') end end |