Class: String

Inherits:
Object
  • Object
show all
Defined in:
lib/omniboard/core_ext.rb

Constant Summary collapse

HTML_ESCAPE_CHARS =
{
  "&" => "&",
  ">" => ">",
  "<" => "&lt;",
  '"' => "&quot;",
  "'" => "&#39;"
}

Instance Method Summary collapse

Instance Method Details

#html_escapeObject



10
11
12
# File 'lib/omniboard/core_ext.rb', line 10

def html_escape
  HTML_ESCAPE_CHARS.reduce(self){ |str, (replace_this, with_this)| str.gsub(replace_this, with_this) }
end

#sanitizeObject

TODO Fix up all of these



15
16
17
# File 'lib/omniboard/core_ext.rb', line 15

def sanitize
	self.gsub('"','\"').gsub("<","&lt;").gsub(">", "&gt;")
end

#sanitize_quotesObject



19
20
21
# File 'lib/omniboard/core_ext.rb', line 19

def sanitize_quotes
	self.gsub('"','&#34;')
end