Class: Amazon::Coral::QueryStringMap
- Defined in:
- lib/amazon/coral/querystringmap.rb
Overview
A hash containing query string parameters that produces a query string via to_s. Also consumes hashes representing hierarchies of data to encode as query parameters.
Instance Method Summary collapse
-
#initialize(hash = {}) ⇒ QueryStringMap
constructor
Instantiate a QueryStringMap with the contents of the specified hash.
-
#to_s ⇒ Object
Returns the query string representation of this map by collapsing its key-value pairs into URL parameters.
Methods inherited from Hash
Constructor Details
#initialize(hash = {}) ⇒ QueryStringMap
Instantiate a QueryStringMap with the contents of the specified hash. If no hash is provided, an empty map is created.
16 17 18 |
# File 'lib/amazon/coral/querystringmap.rb', line 16 def initialize(hash = {}) add_flattened(hash) end |
Instance Method Details
#to_s ⇒ Object
Returns the query string representation of this map by collapsing its key-value pairs into URL parameters.
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/amazon/coral/querystringmap.rb', line 22 def to_s qstr = '' isFirst = true each_pair { |k,v| if isFirst then isFirst = false else qstr << '&' end qstr << UrlEncoding.encode(k.to_s) unless(v.nil?) then qstr << '=' qstr << UrlEncoding.encode(v.to_s) end } return qstr end |