class String def c(*codes) codes = codes.flatten.map { |code| case code when String, Symbol Earthquake.config[:color][code.to_sym] rescue nil else code end }.compact.unshift(0) "\e[#{codes.join(';')}m#{self}\e[0m" end def u gsub(/&(lt|gt|amp|quot|apos);/) do |s| case s when '&' then '&' when '<' then '<' when '>' then '>' when ''' then "'" when '"' then '"' end end end def e gsub(/[&<>'"]/) do |s| case s when '&' then '&' when '<' then '<' when '>' then '>' when "'" then ''' when '"' then '"' end end end end