class Book

Attributes

author[RW]
category[RW]
summary[RW]
title[RW]

Public Class Methods

all() click to toggle source
# File lib/nyt_bestsellers_cli_gem/book.rb, line 20
def self.all
  @@all
end
find_by_title(title) click to toggle source
# File lib/nyt_bestsellers_cli_gem/book.rb, line 24
def self.find_by_title(title)
  self.all.detect {|book| book.title == title}
end
new(title = nil, author = nil, summary = nil, category = nil) click to toggle source
# File lib/nyt_bestsellers_cli_gem/book.rb, line 7
def initialize(title = nil, author = nil, summary = nil, category = nil)
  @title = title
  @author = author
  @summary = summary
  @category = category
  @@all << self
  add_book_to_category(category)
end

Public Instance Methods

add_book_to_category(category) click to toggle source
# File lib/nyt_bestsellers_cli_gem/book.rb, line 16
def add_book_to_category(category)
  Category.all.detect {|type| type.name == category}.books << self
end