Module: GoogleBooks::API

Includes:
HTTParty
Defined in:
lib/google_books/api.rb,
lib/google_books/api/book.rb,
lib/google_books/api/response.rb

Overview

A simple wrapper around the Google Books API

Defined Under Namespace

Classes: Book, Response

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.parametersObject

The search parameters.



8
9
10
# File 'lib/google_books/api.rb', line 8

def parameters
  @parameters
end

Class Method Details

.search(query, opts = {}) ⇒ Object

Queries the Google Books API. Takes a query string and an optional options hash.

The options hash respects the following members:



20
21
22
23
24
25
26
27
28
# File 'lib/google_books/api.rb', line 20

def search(query, opts ={})
  self.parameters = { 'q' => query }
  parameters['startIndex'] = opts[:page]  if opts[:page]
  parameters['maxResults'] = opts[:count] if opts[:count]
  parameters['key'] = opts[:api_key] if opts[:api_key]
  
  result = get(url.to_s)
  Response.new result
end