    # File lib/facets/core/string/rewrite.rb, line 18
      def rewrite(string, rules)
        return nil unless string

        # gmosx: helps to find bugs
        raise ArgumentError.new('The rules parameter is nil') unless rules

        rewritten_string = string.dup

        rules.each do |match,write|
          rewritten_string.gsub!(match,write)
        end

        return (rewritten_string or string)
      end