Sha256: 8b6e1956c066b40412ea4b41b77136cd35f70fc9744e9dd4483f9d05b672a62a

Contents?: true

Size: 581 Bytes

Versions: 1

Compression:

Stored size: 581 Bytes

Contents

require 'uri'
class FsUtils
  
  def self.querystring_from_hash(hash)
    params = hash.map do |k,v|
      k = k.to_s
      if v.is_a? Hash
        v.collect do |k2,v2|
          k2 = k2.to_s
          v2 = v2.to_s
          v2 = url_encode(v2)
          "#{k}.#{k2}=#{v2}"
        end.join('&')
      else
        v = v.to_s
        v = self.url_encode(v)
        k + '=' + v
      end
    end
    params.join('&')
  end
  
  private
  def self.url_encode(string)
    # Taken from http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/156044
    URI.escape(string)
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ruby-fs-stack-0.5.3 lib/ruby-fs-stack/fs_utils.rb