Sha256: bcae6aadd86e25641ef284cf257dbee7b73bfd62a3670a6f761c9883eefe8955
Contents?: true
Size: 970 Bytes
Versions: 1
Compression:
Stored size: 970 Bytes
Contents
require 'cgi' require 'open-uri' require 'ostruct' require 'rubygems' require 'json' require 'googleajax/feed' require 'googleajax/language' require 'googleajax/parser' require 'googleajax/search' require 'googleajax/version' class GoogleAjax API_BASE = 'http://ajax.googleapis.com/ajax/services/' @@api_key = @@referer = nil def self.api_key @@api_key end def self.api_key=(key) @@api_key = key end def self.referer @@referer end def self.referer=(referer) @@referer = referer end def self.get(api, method, query, args = nil) raise "You must assign a value to GoogleAjax.referer" unless @@referer url = "#{API_BASE}#{api}/" url += "#{method}?" url += "&q=#{CGI::escape(query)}" url += "&key=#{api_key}" if api_key url += "&" + args.collect {|key, value| "#{key}=#{value}"}.join('&') if args && !args.empty? data = open(url, "Referer" => @@referer).read Parser.parse(api, method, data) end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
monki-GoogleAjax-0.1.0 | lib/googleajax.rb |