Class: Rowling::Rank

Inherits:
Object
  • Object
show all
Defined in:
lib/rowling/rank.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(response) ⇒ Rank

Returns a new instance of Rank.



4
5
6
7
8
# File 'lib/rowling/rank.rb', line 4

def initialize(response)
  self.date = Rowling::Rank.parse_rank_date(response["BookListDate"])
  self.rank = response["Rank"]
  self.book_list_api_url = response["BookListDate"]["BookListAPIUrl"]
end

Instance Attribute Details

#book_list_api_urlObject

Returns the value of attribute book_list_api_url.



10
11
12
# File 'lib/rowling/rank.rb', line 10

def book_list_api_url
  @book_list_api_url
end

#dateObject

Returns the value of attribute date.



10
11
12
# File 'lib/rowling/rank.rb', line 10

def date
  @date
end

#rankObject

Returns the value of attribute rank.



10
11
12
# File 'lib/rowling/rank.rb', line 10

def rank
  @rank
end

Class Method Details

.parse_rank_date(date_response) ⇒ Object



12
13
14
# File 'lib/rowling/rank.rb', line 12

def self.parse_rank_date(date_response)
  Date.new(date_response["Year"].to_i, date_response["Month"].to_i, date_response["Date"].to_i)
end