Class: Google::CustomSearch::Query

Inherits:
Object
  • Object
show all
Defined in:
lib/google/custom_search/query.rb

Instance Method Summary collapse

Constructor Details

#initialize(query_string, start_index, config = Google::CustomSearch.config) ⇒ Query

Returns a new instance of Query.



16
17
18
19
20
# File 'lib/google/custom_search/query.rb', line 16

def initialize(query_string, start_index, config = Google::CustomSearch.config)
  @query_string = query_string
  @start_index = start_index
  @service = config.service_type.new(config)
end

Instance Method Details

#resultsObject



22
23
24
25
26
27
28
29
30
31
# File 'lib/google/custom_search/query.rb', line 22

def results
  attempts = 5
  begin
    @service.request(@query_string, @start_index)
  rescue BadRequestError
    attempts -= 1
    retry if attempts > 0
    raise
  end
end