Module: URI

Defined in:
lib/webhdfs/backport.rb

Class Method Summary collapse

Class Method Details

.encode_www_form(enum) ⇒ Object


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

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