Class: Gugl::Search::RemoteSearcher
- Inherits:
-
Object
- Object
- Gugl::Search::RemoteSearcher
- Defined in:
- lib/search/remote_searcher.rb
Constant Summary collapse
- ITEMS_RESPONSE_NODE =
'items'
- ERROR_RESPONSE_NODE =
'error'
Instance Attribute Summary collapse
-
#credentials ⇒ Object
Returns the value of attribute credentials.
Instance Method Summary collapse
Instance Attribute Details
#credentials ⇒ Object
Returns the value of attribute credentials.
8 9 10 |
# File 'lib/search/remote_searcher.rb', line 8 def credentials @credentials end |
Instance Method Details
#authorize {|credentials| ... } ⇒ Object
22 23 24 25 |
# File 'lib/search/remote_searcher.rb', line 22 def self.credentials = ApiCredentials.new yield credentials end |
#search(query, limit) ⇒ Object
13 14 15 16 17 18 19 20 |
# File 'lib/search/remote_searcher.rb', line 13 def search(query, limit) data = fetch_and_parse(query, limit) if results = data[ITEMS_RESPONSE_NODE] yield results else raise "Error: #{data[ERROR_RESPONSE_NODE]}" end end |