Permalink
Browse files

Merge pull request #3 from staskie/master

Adding global option to the request
  • Loading branch information...
2 parents d093af6 + dcd64ba commit 511b38ba62d7e4e3e8aa9ecd94959e64549c4ad0 @mattetti committed Jul 13, 2012
Showing with 5 additions and 2 deletions.
  1. +5 −2 lib/ruby-web-search.rb
View
@@ -28,7 +28,7 @@ def self.unthreaded_search(options={})
end
class Query
- attr_accessor :query, :start_index, :result_size, :filter, :country_code, :language_code
+ attr_accessor :query, :start_index, :result_size, :filter, :country_code, :language_code, :global
attr_accessor :safe_search, :type, :custom_search_engine_id, :version, :referer, :request_url
attr_accessor :size, :cursor, :custom_request_url, :response
@@ -77,6 +77,7 @@ def initialize(options={})
@version = options[:version] || "1.0"
@referer = options[:referer] || "http://github.com/mattetti/"
@size = options[:size] || 4
+ @global = options[:global]
@result_size = "large" if size > 4 # increase the result set size to avoid making too many requests
@size = 8 if (@result_size == "large" && size < 8)
end
@@ -92,6 +93,7 @@ def build_request
@request_url << "&start=#{cursor}" if cursor > 0
@request_url << "&lr=#{language_code}" if language_code
@request_url << "&hl=#{country_code}" if country_code
+ @request_url << "&gl=#{global}" if global
puts request_url if $RUBY_WEB_SEARCH_DEBUG
request_url
@@ -110,6 +112,7 @@ def build_requests
url << "&rsz=#{result_size}" if result_size
url << "&lr=#{language_code}" if language_code
url << "&hl=#{country_code}" if country_code
+ url << "&gl=#{global}" if global
url << "&start=#{cursor}"
@cursor += 8
requests << url
@@ -538,4 +541,4 @@ def limit(req_size)
end #of Bing
-end
+end

0 comments on commit 511b38b

Please sign in to comment.