Class: GoogleBooks::API::Response
- Inherits:
-
Object
- Object
- GoogleBooks::API::Response
- Includes:
- Enumerable
- Defined in:
- lib/google_books/api/response.rb
Instance Method Summary collapse
-
#each(&block) ⇒ Object
Iterator for looping through the results.
-
#initialize(results) ⇒ Response
constructor
A new instance of Response.
-
#total_results ⇒ Object
The total number of results that were found for your query (not the count of the results returned).
Constructor Details
#initialize(results) ⇒ Response
Returns a new instance of Response.
6 7 8 |
# File 'lib/google_books/api/response.rb', line 6 def initialize(results) @results = results end |
Instance Method Details
#each(&block) ⇒ Object
Iterator for looping through the results
11 12 13 14 15 |
# File 'lib/google_books/api/response.rb', line 11 def each(&block) @results['items'].each do |item| block.call(Book.new(item)) end end |
#total_results ⇒ Object
The total number of results that were found for your query (not the count of the results returned)
18 19 20 |
# File 'lib/google_books/api/response.rb', line 18 def total_results @results['totalItems'].to_i end |