Class: GoogleSearch

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

Class Method Summary collapse

Class Method Details

.default_optionsObject

:singleton-method: Default options that should be present in every request



26
27
28
# File 'lib/google_search/google_search.rb', line 26

def default_options
  @default_options ||= {}
end

.default_options=(options) ⇒ Object

:singleton-method: Sets up default options that should be present in every request



33
34
35
# File 'lib/google_search/google_search.rb', line 33

def default_options=(options)
  @default_options = options
end

.method_missing(method, args) ⇒ Object

:nodoc:



37
38
39
40
# File 'lib/google_search/google_search.rb', line 37

def method_missing(method, args) # :nodoc:
  raise "Unknown search type '#{method}'" unless supported_search_types.include?(method)
  query(method, args)
end

.with_pages(pages) ⇒ Object

Yields the search method for number pages specified. Each page will contain 8 results, pages must be something enumerable



44
45
46
47
48
49
50
51
# File 'lib/google_search/google_search.rb', line 44

def with_pages(pages)
  orig_options = default_options.clone 
  pages.each do |page|
    default_options.merge!(:rsz => "large", :start => (page - 1) * 8)
    yield
  end
  default_options = orig_options
end