Class: Google::Search::News

Inherits:
Google::Search show all
Includes:
OrderBy
Defined in:
lib/google-search/search/news.rb

Constant Summary collapse

TOPICS =

– Constants ++

:headlines, :world, :business, :nation, :science, 
:elections, :politics, :entertainment, :sports, :health

Constants included from OrderBy

OrderBy::ORDER_BY

Constants inherited from Google::Search

URI, VERSION

Instance Attribute Summary collapse

Attributes included from OrderBy

#order_by

Attributes inherited from Google::Search

#api_key, #language, #offset, #options, #query, #sent, #size, #type, #version

Instance Method Summary collapse

Methods inherited from Google::Search

#all_items, #each_item, #each_response, #get_hash, #get_raw, #get_response, #get_uri, json_decode, #next, size_for, url_encode, #validate

Constructor Details

#initialize(options = {}, &block) ⇒ News

:nodoc:


48
49
50
51
52
# File 'lib/google-search/search/news.rb', line 48

def initialize options = {}, &block
  @relative_to = options.delete :relative_to
  @edition = options.delete :edition
  super
end

Instance Attribute Details

#editionObject

Edition, such as :us, :uk, :fr_ca, etc.


44
45
46
# File 'lib/google-search/search/news.rb', line 44

def edition
  @edition
end

#relative_toObject

Relative to city, state, province, zipcode, etc.


22
23
24
# File 'lib/google-search/search/news.rb', line 22

def relative_to
  @relative_to
end

#topicObject

Topic:

- :headlines
- :world
- :business
- :nation
- :science
- :elections
- :politics
- :entertainment
- :sports
- :health

39
40
41
# File 'lib/google-search/search/news.rb', line 39

def topic
  @topic
end

Instance Method Details

#get_uri_paramsObject

:nodoc:


56
57
58
59
60
61
62
63
# File 'lib/google-search/search/news.rb', line 56

def get_uri_params
  validate(:topic) { |topic| topic.nil? || TOPICS.include?(topic) }
  super + [
    [:geo, relative_to],
    [:topic, topic],
    [:ned, edition]
    ]
end