Module: SunDawg::Util

Defined in:
lib/util.rb

Class Method Summary collapse

Class Method Details

.build_query_string(params) ⇒ Object



7
8
9
10
11
12
13
# File 'lib/util.rb', line 7

def self.build_query_string(params) 
  s = "?"
  params.each { |k, v|
    s += "#{k}=#{CGI.escape(v)}&" unless v.nil?
  } 
  s
end

.do_http_get(url, endpoint) ⇒ Object



15
16
17
18
19
20
21
22
# File 'lib/util.rb', line 15

def self.do_http_get(url, endpoint)
  url = URI.parse("#{url}#{endpoint}")
  req = Net::HTTP::Get.new(endpoint)
  res = Net::HTTP.start(url.host, url.port) { |http|
    http.request(req)
  }
  res.body
end