Module: NetDNARWS::Utils

Included in:
NetDNA
Defined in:
lib/netdnarws.rb

Constant Summary collapse

RESERVED_CHARACTERS =
/[^a-zA-Z0-9\-\.\_\~]/

Instance Method Summary collapse

Instance Method Details

#encode_params(params = {}) ⇒ Object



143
144
145
# File 'lib/netdnarws.rb', line 143

def encode_params params={}
  Hash[params.map { |k, v| [NetDNARWS::Utils::escape(k), NetDNARWS::Utils::escape(v)] }]
end

#escape(value) ⇒ Object



137
138
139
140
141
# File 'lib/netdnarws.rb', line 137

def escape(value)
  URI::escape(value.to_s, NetDNARWS::Utils::RESERVED_CHARACTERS)
rescue ArgumentError
  URI::escape(value.to_s.force_encoding(Encoding::UTF_8), NetDNARWS::Utils::RESERVED_CHARACTERS)
end