Module: GoogleBooks
- Includes:
- HTTParty
- Defined in:
- lib/version.rb,
lib/book/item.rb,
lib/googlebooks.rb,
lib/book/response.rb
Defined Under Namespace
Constant Summary collapse
- VERSION =
"0.0.9"
Class Attribute Summary collapse
-
.parameters ⇒ Object
Returns the value of attribute parameters.
Class Method Summary collapse
-
.search(query, options = {}, remote_ip = nil) ⇒ Object
3rd parameter optionally passes user’s IP address * User IP may be require in order for request to be made to the Google API from applications residing on decentralized cloud servers See www.google.com/support/forum/p/booksearch-apis/thread?tid=2034bed9a98c15cb&hl=en.
Class Attribute Details
.parameters ⇒ Object
Returns the value of attribute parameters.
14 15 16 |
# File 'lib/googlebooks.rb', line 14 def parameters @parameters end |
Class Method Details
.search(query, options = {}, remote_ip = nil) ⇒ Object
3rd parameter optionally passes user’s IP address
-
User IP may be require in order for request to be made to the Google API from applications residing on decentralized cloud servers See www.google.com/support/forum/p/booksearch-apis/thread?tid=2034bed9a98c15cb&hl=en
30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/googlebooks.rb', line 30 def search(query, = {}, remote_ip = nil) (headers 'X-Forwarded-For' => remote_ip.to_s) unless remote_ip.nil? self.parameters = { 'q' => query } [:page] ||= 1 [:count] ||= 5 parameters['filter'] = [:filter] if [:filter] parameters['startIndex'] = [:count] * ([:page] - 1) parameters['maxResults'] = [:count] parameters['key'] = [:api_key] if [:api_key] parameters['orderBy'] = 'newest' if [:order_by].eql?('newest') parameters['country'] = [:country] Response.new(get(url.to_s)) end |