Class: AddressFinder::Util

Inherits:
Object
  • Object
show all
Defined in:
lib/addressfinder/util.rb

Class Method Summary collapse

Class Method Details

.encode(v) ⇒ Object



5
6
7
# File 'lib/addressfinder/util.rb', line 5

def self.encode(v)
  CGI.escape(v.to_s)
end

.encode_and_join_params(params) ⇒ Object



9
10
11
12
13
14
15
16
17
18
# File 'lib/addressfinder/util.rb', line 9

def self.encode_and_join_params(params)
  # URI.encode_www_form(params)
  params.map do |k, v|
    if v.is_a? Array
      v.collect { |e| "#{k}[]=#{encode(e)}" }
    else
      "#{k}=#{encode(v)}"
    end
  end.join("&")
end