Skip to content

Commit

Permalink
Added News topic
Browse files Browse the repository at this point in the history
  • Loading branch information
tj committed Jul 24, 2009
1 parent c4545a2 commit f92fa76
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
7 changes: 7 additions & 0 deletions lib/google-search/search.rb
@@ -1,3 +1,10 @@

require 'google-search/search/base'
require 'google-search/search/web'
require 'google-search/search/blog'
require 'google-search/search/image'
require 'google-search/search/local'
require 'google-search/search/news'
require 'google-search/search/video'
require 'google-search/search/book'
require 'google-search/search/patent'
20 changes: 20 additions & 0 deletions lib/google-search/search/news.rb
Expand Up @@ -8,6 +8,8 @@ class News < self
#++

ORDER_BY = :relevance, :date
TOPICS = :headlines, :world, :business, :nation, :science,
:elections, :politics, :entertainment, :sports, :health

##
# Order by. Defaults to :relevance
Expand All @@ -24,6 +26,23 @@ class News < self

attr_reader :relative_to

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

attr_reader :topic

#:nodoc:

def initialize options = {}, &block
Expand All @@ -36,6 +55,7 @@ def initialize options = {}, &block

def get_uri_params
raise Error, "invalid order `#{order_by}'" unless order_by.nil? || ORDER_BY.include?(order_by)
raise Error, "invalid topic `#{topic}'" unless topic.nil? || TOPICS.include?(topic)
super + [
[:scoring, order_by ? 'd' : nil],
[:geo, relative_to]
Expand Down

0 comments on commit f92fa76

Please sign in to comment.