class BestReads::Book

Attributes

author[RW]
display[R]
rating[RW]
title[RW]
url[RW]

Public Class Methods

all() click to toggle source
# File lib/best_reads/book.rb, line 24
def self.all
  @@all
end
create_and_display_from_collection(book_hash) click to toggle source
# File lib/best_reads/book.rb, line 6
def self.create_and_display_from_collection(book_hash)
  book_hash.each_with_index do |book, index|
    new_book = self.new()
    book.each {|key, value| new_book.send(("#{key}="),value.strip)}
    new_book.save
    new_book.display_by_index(index)
  end
end

Public Instance Methods

display_by_index(index) click to toggle source
# File lib/best_reads/book.rb, line 15
def display_by_index(index)
  puts "#{index+1}. #{self.title} by #{self.author}"
  puts "rating: #{self.rating}"
end
save() click to toggle source
# File lib/best_reads/book.rb, line 20
def save
  self.class.all<<self
end