Module: IfdTools::ApplicationHelper

Defined in:
app/helpers/ifd_tools/application_helper.rb

Instance Method Summary collapse

Instance Method Details

#cleanse_for_flash(str) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'app/helpers/ifd_tools/application_helper.rb', line 8

def cleanse_for_flash(str)

  s = str.gsub(%r{>\s+}, ">").gsub(%r{</p>}, "</p><br />")

  replacements = []
  replacements << { find: %w(&amp;trade; &trade;), replace: "&#8482;" }
  replacements << { find: %w(&amp;copy; &copy;), replace: "&#169;" }
  replacements << { find: %w(&amp;reg; &reg;), replace: "&#174;" }
  replacements << { find: %w(&amp;rsquo; &rsquo;), replace: "'" }
  replacements << { find: %w(&amp;rdquo; &rdquo;), replace: '"' }
  replacements << { find: %w(&amp;bull; &bull;), replace: "&#149;" }
  replacements << { find: %w(&amp;hellip; &hellip;), replace: "..." }
  replacements << { find: %w(&amp;ndash; &ndash; &amp;mdash; &mdash;), replace: "-" }

  replacements.map do |repl|
    repl[:find].map { |find| s.gsub! find, repl[:replace] }
  end

  s
end

#phone_number(num) ⇒ Object



4
5
6
# File 'app/helpers/ifd_tools/application_helper.rb', line 4

def phone_number(num)
  number_to_phone num, area_code: true, delimiter: "."
end