Class: Crowdskout::Util::Helpers

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

Class Method Summary collapse

Class Method Details

.encode(str) ⇒ Object

Escape special characters

Parameters:

  • str (String)


21
22
23
# File 'lib/crowdskout/util/helpers.rb', line 21

def encode(str)
  CGI.escape(str).gsub('.', '%2E').gsub('-', '%2D')
end

.http_build_query(params) ⇒ String

Build the HTTP query from the given parameters

Parameters:

  • params (Hash)

Returns:

  • (String)

    query string



15
16
17
# File 'lib/crowdskout/util/helpers.rb', line 15

def http_build_query(params)
  params.collect{ |k,v| "#{k.to_s}=#{encode(v.to_s)}" }.reverse.join('&')
end