lib/ratebeer/scraping.rb
# Fix characters in string scraped from website.
#
# This method substitutes problematic characters found in
# strings scraped from RateBeer.com
#
Fix characters in string scraped from website.
This method substitutes problematic characters found in
strings scraped from RateBeer.com
Fix characters in string scraped from website . This method substitutes problematic characters found in strings scraped from RateBeer . com
def fix_characters(string)
      string = string.encode('UTF-8', invalid: :replace, undef: :replace, replace: '')
      characters = { nbsp     => " ",
                     "\u0093" => "ž",
                     "\u0092" => "'",
                     "\u0096" => "–",
                     / {2,}/ => " " }
      characters.each { |c, r| string.gsub!(c, r) }
      string.strip
    end
def fix_characters ( string ) string = string . encode ( 'UTF-8' , invalid : :replace , undef : :replace , replace : '' ) characters = { nbsp => " " , "\u0093" => "ž", "\u0092" => "'" , "\u0096" => "–", /  {2,} / => " " } characters . each { | c , r | string . gsub! ( c , r ) } string . strip end
Fix characters in string scraped from website.
Fix characters in string scraped from website .
string