class ScrapeGot::Books
Attributes
name[RW]
number_of_pages[RW]
released[RW]
Public Class Methods
all_books()
click to toggle source
# File lib/scrape_got/books.rb, line 7 def self.all_books @@all_books ||= self.load_books end
load_books()
click to toggle source
# File lib/scrape_got/books.rb, line 11 def self.load_books API.get_books.collect do |book_hash| Books.new(book_hash) end end
new(attributes = {})
click to toggle source
# File lib/scrape_got/books.rb, line 17 def initialize(attributes = {}) @name = attributes["name"] @number_of_pages = attributes["numberOfPages"] @released = attributes["released"] end
print_books()
click to toggle source
# File lib/scrape_got/books.rb, line 23 def self.print_books Books.all_books.each.with_index(1) do |book, index| puts "Book #{index}: #{book.name}, released: #{book.released}" end end