Class: Hash

Inherits:
Object
  • Object
show all
Defined in:
lib/withings-api/query_string.rb

Constant Summary collapse

QUERY_STRING_RESERVERED =
/[\$&\+,\/:;=\?@ <>"#%\{\}\|\\\^~\[\]`]/

Instance Method Summary collapse

Instance Method Details

#to_query_stringObject



6
7
8
9
10
11
12
13
14
15
# File 'lib/withings-api/query_string.rb', line 6

def to_query_string
  hash = self

  params = []
  hash.keys.each do |key|
    params << [key, hash[key]]
  end

  params.map { |p| p.map { |v| URI.escape(v.to_s, QUERY_STRING_RESERVERED) }.join("=") }.join("&")
end