Class: UsaTodayBooks::BestSellers
- Inherits:
-
Object
- Object
- UsaTodayBooks::BestSellers
- Includes:
- HTTParty
- Defined in:
- lib/usa_today_books/best_sellers.rb
Instance Attribute Summary collapse
-
#api_key ⇒ Object
readonly
Returns the value of attribute api_key.
Instance Method Summary collapse
- #booklists(options = {}) ⇒ Object
- #categories(options = {}) ⇒ Object
- #classes(options = {}) ⇒ Object
- #dates(options = {}) ⇒ Object
-
#initialize(options = {}) ⇒ BestSellers
constructor
A new instance of BestSellers.
- #titles(options = {}) ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ BestSellers
Returns a new instance of BestSellers.
9 10 11 |
# File 'lib/usa_today_books/best_sellers.rb', line 9 def initialize(={}) @api_key = [:api_key] || UsaTodayBooks.api_key end |
Instance Attribute Details
#api_key ⇒ Object (readonly)
Returns the value of attribute api_key.
7 8 9 |
# File 'lib/usa_today_books/best_sellers.rb', line 7 def api_key @api_key end |
Instance Method Details
#booklists(options = {}) ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/usa_today_books/best_sellers.rb', line 32 def booklists(={}) year = .delete(:year) month = .delete(:month) date = .delete(:date) if year && month && date endpoint = "/booklists/#{year}/#{month}/#{date}" elsif year && month.nil? && date.nil? endpoint = "/booklists/#{year}" elsif month && year && date.nil? endpoint = "/booklists/#{year}/#{month}" else endpoint = "/booklists" end mashup(self.class.get(endpoint, :query => .merge(self.))) end |
#categories(options = {}) ⇒ Object
50 51 52 |
# File 'lib/usa_today_books/best_sellers.rb', line 50 def categories(={}) mashup(self.class.get("/categories", :query => .merge(self.))) end |
#classes(options = {}) ⇒ Object
54 55 56 |
# File 'lib/usa_today_books/best_sellers.rb', line 54 def classes(={}) mashup(self.class.get("/classes", :query => .merge(self.))) end |
#dates(options = {}) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/usa_today_books/best_sellers.rb', line 13 def dates(={}) year = .delete(:year) month = .delete(:month) minyear = .delete(:minyear) maxyear = .delete(:maxyear) = {:minyear => minyear, :maxyear => maxyear} if year && month endpoint = "/dates/#{year}/#{month}" elsif year && month.nil? endpoint = "/dates/#{year}" else endpoint = "/dates" end mashup(self.class.get(endpoint, :query => .merge(self.))) end |
#titles(options = {}) ⇒ Object
58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/usa_today_books/best_sellers.rb', line 58 def titles(={}) title = .delete(:title) isbn = .delete(:isbn) if title endpoint = "/titles/#{title}" elsif isbn endpoint = "/titles/#{isbn}" else endpoint = "/titles" end mashup(self.class.get(endpoint, :query => .merge(self.))) end |