Class: HoboFields::Text

Inherits:
String
  • Object
show all
Defined in:
lib/hobo_fields/text.rb

Direct Known Subclasses

RawHtmlString, RawMarkdownString, TextileString

Constant Summary collapse

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

Instance Method Summary collapse

Instance Method Details

#to_html(xmldoctype = true) ⇒ Object



9
10
11
# File 'lib/hobo_fields/text.rb', line 9

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