Module: URI

Defined in:
lib/webhdfs/backport.rb

Class Method Summary collapse

Class Method Details

.encode_www_form(enum) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/webhdfs/backport.rb', line 12

def self.encode_www_form(enum)
  enum.map do |key, value|
    if value.nil?
      CGI.escape(key)
    elsif value.respond_to?(:to_ary)
      value.to_ary.map do |w|
        str = CGI.escape(key)
        str << '=' << CGI.escape(w) unless w.nil?
      end.join('&')
    else
      CGI.escape(key.to_s) << '=' << CGI.escape(value.to_s)
    end
  end.join('&')
end