Sha256: f349f4ba733fd8f0292ddb01eaa3f7fb4273a4c4dea86a75e5aa784ab854d077
Contents?: true
Size: 622 Bytes
Versions: 9
Compression:
Stored size: 622 Bytes
Contents
require 'book/item' module GoogleBooks class Response include Enumerable def initialize(response) @response = response end # Returns nil if no records are returned. Otherwise, response returns # hash of generally unusable Google API specific data. def each(&block) return [] if total_items == 0 @response['items'].each do |item| block.call(Item.new(item)) end end # Total items returnable based on query, not total items in response # (which is throttled by maxResults) def total_items @response['totalItems'].to_i end end end
Version data entries
9 entries across 9 versions & 1 rubygems