Sha256: f203fb9a774f7dd1a27799afe80ebbcc2525ab089e917c24338d75d79f062b62

Contents?: true

Size: 980 Bytes

Versions: 1

Compression:

Stored size: 980 Bytes

Contents

module RiCal
  class PropertyValue
    # RiCal::PropertyValue::Text represents an icalendar Text property value
    # which is defined in 
    # rfc 2445 section 4.3.11 pp 45-46
    class Text < PropertyValue
      
      # Return the string value of the receiver
      def ruby_value
        if value
          value.gsub(/\\[;,nN\\]/) {|match|
            case match[1,1]
            when /[,;\\]/
              match[1,1]
            when 'n', 'N'
              "\n"
            else
              match
            end
          }
        else
          nil
        end
      end
      
      def to_ri_cal_text_property
        self
      end
      
      def self.convert(parent, string) #:nodoc:
        ical_str = string.gsub(/\n\r?|\r\n?|,|;|\\/) {|match|
          if ["\n", "\r", "\n\r", "\r\n"].include?(match)
            '\\n'
          else
            "\\#{match}"
          end
          }
        self.new(parent, :value => ical_str)
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
friflaj_ri_cal-0.9.0 lib/ri_cal/property_value/text.rb