Class: StatHat::Common

Inherits:
Object
  • Object
show all
Defined in:
lib/stathat.rb

Constant Summary collapse

CLASSIC_VALUE_URL =
"http://api.stathat.com/v"
CLASSIC_COUNT_URL =
"http://api.stathat.com/c"
EZ_URL =
"http://api.stathat.com/ez"

Class Method Summary collapse

Class Method Details

.send_to_stathat(url, args) ⇒ Object

def send_to_stathat(url, args)

uri = URI.parse(url)
uri.query = URI.encode_www_form(args)
resp = Net::HTTP.get(uri)
return Response.new(resp)

end



22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/stathat.rb', line 22

def send_to_stathat(url, args)
        uri = URI.parse(url)

        begin
                uri.query = URI.encode_www_form(args)
        rescue NoMethodError => e
                # backwards compatability for pre 1.9.x
                uri.query = args.map { |arg, val| arg.to_s + "=" + CGI::escape(val.to_s) }.join('&')
        end

        resp = Net::HTTP.get(uri)
        return Response.new(resp)
end