Class: AddressFinder::Util

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

Class Method Summary collapse

Class Method Details

.encode(v) ⇒ Object



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

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

.encode_and_join_params(params) ⇒ Object



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

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