Class: Fetch::URLSearchParams
- Defined in:
- lib/fetch/url_search_params.rb
Instance Attribute Summary
Attributes inherited from MultiMap
Instance Method Summary collapse
-
#initialize(options = []) ⇒ URLSearchParams
constructor
A new instance of URLSearchParams.
- #sort ⇒ Object
- #to_s ⇒ Object
Methods inherited from MultiMap
#append, #delete, #each, #get, #get_all, #has, #keys, #set, #values
Constructor Details
#initialize(options = []) ⇒ URLSearchParams
Returns a new instance of URLSearchParams.
7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/fetch/url_search_params.rb', line 7 def initialize( = []) super() case when String initialize(URI.decode_www_form(.delete_prefix('?'))) when Enumerable .each do |k, v| append k, v end else raise ArgumentError end end |
Instance Method Details
#sort ⇒ Object
22 23 24 |
# File 'lib/fetch/url_search_params.rb', line 22 def sort entries.sort_by!(&:first) end |
#to_s ⇒ Object
26 27 28 |
# File 'lib/fetch/url_search_params.rb', line 26 def to_s URI.encode_www_form(entries) end |