# String Hacks: # 1. SEO friendly. # This method is used in the AR seo hack. It takes a string and makes it # seo friendly. # # Example: # c.title = " Rails is freaking awesome, didn't you know that? " # c.title.seo_friendly # => "rails-is-freaking-awesome-didnt-you-know-that" class String def seo_friendly gsub(/['"]/, "").gsub(/\W/, " ").squeeze(' ').strip.gsub(/\s/, "-").downcase end def rubify downcase.gsub(/\W/, ' ').squeeze(' ').strip.gsub(/\s/, '_') end def rubify! replace rubify end def proper_case to_s.humanize.split(/\s/).map { |e| e.capitalize }.join(" ") end end