Module: Google::Book

Includes:
HTTParty
Defined in:
lib/google/book.rb,
lib/google/book/cover.rb,
lib/google/book/entry.rb,
lib/google/book/version.rb,
lib/google/book/response.rb

Overview

A simple wrapper around the Google Book Search API.

Defined Under Namespace

Classes: Cover, Entry, Response

Constant Summary collapse

VERSION =
'0.4.0'

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.parametersObject

The search parameters.



15
16
17
# File 'lib/google/book.rb', line 15

def parameters
  @parameters
end

Class Method Details

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

Queries the Google Book Search Data API. Takes a query string and an optional options hash.

The options hash respects the following members:

  • ‘:page`, which specifies the page.

  • ‘:count`, which specifies the number of results per page.



25
26
27
28
29
30
31
# File 'lib/google/book.rb', line 25

def search(query, opts = {})
  self.parameters = { 'q' => query }
  parameters['start-index'] = opts[:page]  if opts[:page]
  parameters['max-results'] = opts[:count] if opts[:count]

  Response.new(get(url.to_s))
end