Sha256: 3831b37af0eab8d1a40a5ae2b8d46f404c48fe54712249cd3780744e3d6fb6f5

Contents?: true

Size: 387 Bytes

Versions: 5

Compression:

Stored size: 387 Bytes

Contents

module HoboFields
  module Types
    class Text < String

      HTML_ESCAPE = { '&' => '&amp;', '"' => '&quot;', '>' => '&gt;', '<' => '&lt;' }

      COLUMN_TYPE = :text

      def to_html(xmldoctype = true)
        gsub(/[&"><]/) { |special| HTML_ESCAPE[special] }.gsub("\n", "<br#{xmldoctype ? ' /' : ''}>\n")
      end

      HoboFields.register_type(:text, self)

    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
hobo_fields-1.3.0.pre14 lib/hobo_fields/types/text.rb
hobo_fields-1.3.0.pre13 lib/hobo_fields/types/text.rb
hobo_fields-1.3.0.pre12 lib/hobo_fields/types/text.rb
hobo_fields-1.3.0.pre11 lib/hobo_fields/types/text.rb
hobo_fields-1.3.0.pre10 lib/hobo_fields/types/text.rb