Module: Cleaners::ReplaceHTMLMarkup
- Defined in:
- lib/data_cleansing/cleaners.rb
Overview
Unescape HTML Markup ( case-insensitive )
Constant Summary collapse
- HTML_MARKUP =
Regexp.compile(/&(amp|quot|gt|lt|apos|nbsp);/in)
Class Method Summary collapse
Class Method Details
.call(string) ⇒ Object
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/data_cleansing/cleaners.rb', line 61 def self.call(string) return string unless string.is_a?(String) string.gsub!(HTML_MARKUP) do |match| case match.downcase when '&' then '&' when '"' then '"' when '>' then '>' when '<' then '<' when ''' then "'" when ' ' then ' ' else "&#{match};" end end || string end |