Class: Google::CustomSearch::JSON::Service
- Inherits:
-
Object
- Object
- Google::CustomSearch::JSON::Service
- Defined in:
- lib/google/custom_search/json/service.rb
Instance Method Summary collapse
-
#initialize(config) ⇒ Service
constructor
A new instance of Service.
- #request(query_string, start_index) ⇒ Object
Constructor Details
#initialize(config) ⇒ Service
Returns a new instance of Service.
9 10 11 12 |
# File 'lib/google/custom_search/json/service.rb', line 9 def initialize(config) @config = config @resource = RestClient::Resource.new('https://www.googleapis.com/customsearch/v1') end |
Instance Method Details
#request(query_string, start_index) ⇒ Object
14 15 16 17 18 19 20 21 |
# File 'lib/google/custom_search/json/service.rb', line 14 def request(query_string, start_index) @resource.get(:params => params(query_string, start_index)) do |response, request, result| unless response.code == 200 raise BadRequestError, "Unable to fetch results from Google: #{response}" end Results.new(response) end end |