Sha256: 120ae94914f3d5dd41f4637cf84922dccd3dc48579401040a9da1f06b45c8dda

Contents?: true

Size: 978 Bytes

Versions: 1

Compression:

Stored size: 978 Bytes

Contents

module RiCal
  class PropertyValue
    #- ©2009 Rick DeNatale
    #- All rights reserved. Refer to the file README.txt for the license
    #
    # 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 self.convert(parent, string) #:nodoc:
        ical_str = string.gsub(/\n|,|;/) {|match|
          if match == "\n"
            '\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
rubyredrick-ri_cal-0.0.2 lib/ri_cal/property_value/text.rb