class Rowling::Book

Constants

ATTRIBUTES

Public Class Methods

new(response) click to toggle source
# 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