Module: Goodreads::Shelves
- Included in:
- Client
- Defined in:
- lib/goodreads/client/shelves.rb
Instance Method Summary collapse
-
#shelf(user_id, shelf_name, options = {}) ⇒ Object
Get books from a user’s shelf.
Instance Method Details
#shelf(user_id, shelf_name, options = {}) ⇒ Object
Get books from a user’s shelf
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/goodreads/client/shelves.rb', line 5 def shelf(user_id, shelf_name, ={}) = .merge(:shelf => shelf_name, :v =>2) data = request("/review/list/#{user_id}.xml", ) 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 |