Class: Rowling::BookList
- Inherits:
-
Object
- Object
- Rowling::BookList
- Defined in:
- lib/rowling/book_list.rb
Instance Attribute Summary collapse
-
#book_list_api_url ⇒ Object
Returns the value of attribute book_list_api_url.
-
#books ⇒ Object
Returns the value of attribute books.
-
#date ⇒ Object
Returns the value of attribute date.
-
#name ⇒ Object
Returns the value of attribute name.
Instance Method Summary collapse
-
#initialize(response) ⇒ BookList
constructor
A new instance of BookList.
- #parse_date(date_response) ⇒ Object
- #parse_entries(entries_response) ⇒ Object
Constructor Details
#initialize(response) ⇒ BookList
Returns a new instance of BookList.
3 4 5 6 7 8 |
# File 'lib/rowling/book_list.rb', line 3 def initialize(response) self.books = parse_entries(response["BookListEntries"]) self.date = parse_date(response["BookListDate"]) self.name = response["Name"] self.book_list_api_url = response["BookListDate"]["BookListAPIUrl"] end |
Instance Attribute Details
#book_list_api_url ⇒ Object
Returns the value of attribute book_list_api_url.
10 11 12 |
# File 'lib/rowling/book_list.rb', line 10 def book_list_api_url @book_list_api_url end |
#books ⇒ Object
Returns the value of attribute books.
10 11 12 |
# File 'lib/rowling/book_list.rb', line 10 def books @books end |
#date ⇒ Object
Returns the value of attribute date.
10 11 12 |
# File 'lib/rowling/book_list.rb', line 10 def date @date end |
#name ⇒ Object
Returns the value of attribute name.
10 11 12 |
# File 'lib/rowling/book_list.rb', line 10 def name @name end |
Instance Method Details
#parse_date(date_response) ⇒ Object
12 13 14 15 16 |
# File 'lib/rowling/book_list.rb', line 12 def parse_date(date_response) date_vals = [date_response["Year"], date_response["Month"], date_response["Date"]] date_vals = date_vals.compact.map(&:to_i) Date.new(*date_vals) end |