Class: Rowling::Book
- Inherits:
-
Object
- Object
- Rowling::Book
- Defined in:
- lib/rowling/book.rb
Constant Summary collapse
- ATTRIBUTES =
[:title, :title_api_url, :author, :class, :description, :book_list_appearances, :highest_rank, :rank_last_week, :isbn, :asin]
Instance Method Summary collapse
-
#initialize(response) ⇒ Book
constructor
A new instance of Book.
Constructor Details
#initialize(response) ⇒ Book
Returns a new instance of Book.
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/rowling/book.rb', line 5 def initialize(response) ATTRIBUTES.each do |key| send("#{key}=", response[key.to_s.camelize]) if response[key.to_s.camelize] end if descrip = response["BriefDescription"] self.description = descrip end if response["Category"] self.category_id = response["Category"]["CategoryID"] self.category_name = response["Category"]["CategoryName"] end if response["RankHistories"] self.ranks = response["RankHistories"].map do |rank| Rowling::Rank.new(rank) end end end |