module CliTrivia::Filter

Public Instance Methods

format_string(fsg) click to toggle source

A method available to all classes that passes in a string and replaces unreadable characters with escaped punctuation. Used by question text and answers.

# File lib/concerns/filter.rb, line 5
def format_string(fsg)
  fsg = fsg.gsub(/"/, "'")
  fsg = fsg.gsub(/&/, '&')
  fsg = fsg.gsub(/ò/, 'o')
  fsg = fsg.gsub(/ö/, 'o')
  fsg = fsg.gsub(/ó/, 'o')
  fsg = fsg.gsub(/ã/, 'a')
  fsg = fsg.gsub(/ü/, 'u')
  fsg = fsg.gsub(/Ö/, 'O')
  fsg = fsg.gsub(/′/, "'")
  fsg = fsg.gsub(/″/, '"')
  fsg = fsg.gsub(/í/, 'i')
  fsg = fsg.gsub(/á/, 'a')
  fsg = fsg.gsub(/é/, 'e')
  fsg = fsg.gsub(/'/, "'")
  fsg = fsg.gsub(/“/, '"')
  fsg = fsg.gsub(/”/, '"')
  fsg = fsg.gsub(/’/, "'")
  fsg = fsg.gsub(/‘/, "'")
  fsg = fsg.gsub(/ñ/, 'n')
  fsg = fsg.gsub(/‎/, '')
  fsg
end