Sha256: 2fabae23c93219d9d480575a2702274b54d8e006c7f92363f735885253fcabd1

Contents?: true

Size: 726 Bytes

Versions: 9

Compression:

Stored size: 726 Bytes

Contents

module Goodreads
  module Shelves

    # Get books from a user's shelf
    def shelf(user_id, shelf_name, options={})
      options = options.merge(:shelf => shelf_name, :v =>2)
      data = request("/review/list/#{user_id}.xml", options)
      reviews = data['reviews']['review']

      books = []
      unless reviews.nil?
        # one-book results come back as a single hash
        reviews = [reviews] if !reviews.instance_of?(Array) 
        books = reviews.map {|e| Hashie::Mash.new(e)} 
      end

      Hashie::Mash.new({
        :start => data['reviews']['start'].to_i,
        :end => data['reviews']['end'].to_i,
        :total => data['reviews']['total'].to_i,
        :books => books
      })
    end

  end
end

Version data entries

9 entries across 9 versions & 2 rubygems

Version Path
goodreads-0.4.3 lib/goodreads/client/shelves.rb
goodreads-0.4.2 lib/goodreads/client/shelves.rb
goodreads-0.4.1 lib/goodreads/client/shelves.rb
goodreads-0.4.0 lib/goodreads/client/shelves.rb
goodreads-0.3.0 lib/goodreads/client/shelves.rb
goodreads_17up-0.2.2 lib/goodreads/client/shelves.rb
goodreads-0.2.2 lib/goodreads/client/shelves.rb
goodreads_17up-0.2.1 lib/goodreads/client/shelves.rb
goodreads-0.2.1 lib/goodreads/client/shelves.rb