Sha256: c2c4b3f30de8c99a746550c789e29b2fbad66fce1e4daf13f11ce13a397032c2

Contents?: true

Size: 406 Bytes

Versions: 2

Compression:

Stored size: 406 Bytes

Contents

module MWS
  class QueryString < ::String
    class UriEncoder
      NO_ENCODE_CHARACTERS = /[A-Za-z0-9\-\_\.\~]/

      def encode(string)
        string.to_s.each_char.map{|char| char.match(NO_ENCODE_CHARACTERS) ? char : escape_char(char) }.join("")
      end

      private

      def escape_char(char)
        char.each_byte.map{|byte| "%#{byte.to_s(16).upcase}" }.join("")
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
marketplace_web_service-0.0.3 lib/mws/query_string/uri_encoder.rb
marketplace_web_service-0.0.2 lib/mws/query_string/uri_encoder.rb