Sha256: acb90a58fed86695d637a378377b08e8671be48973c290bd19b05d32f4dcc453

Contents?: true

Size: 741 Bytes

Versions: 1

Compression:

Stored size: 741 Bytes

Contents

module Google
  module Book
    class Response
      def initialize(hash)
        @feed = hash['feed']
      end

      def to_books
        [@feed['entry']].flatten.map do |hash|
          book = Struct.new(
            Cover.new(hash['link'][0]['href']),
            hash['link'][1]['href'],
            hash['link'][2]['href'],
            [hash['dc:creator']].flatten,
            hash['dc:date'],
            hash['dc:description'],
            [hash['dc:format']].flatten,
            hash['dc:identifier'],
            hash['dc:publisher'],
            hash['dc:subject'],
            [hash['dc:title']].flatten)
        end
      end

      def total_results
        @feed['openSearch:totalResults'].to_i
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
google-book-0.2.1 lib/google/book/response.rb