class NytCli::Book
Attributes
buy_links[RW]
description[RW]
rank[RW]
title[RW]
Public Class Methods
all()
click to toggle source
# File lib/nyt_cli/book.rb, line 34 def self.all @@all end
all_viewed()
click to toggle source
# File lib/nyt_cli/book.rb, line 38 def self.all_viewed @@all_selected end
collection()
click to toggle source
# File lib/nyt_cli/book.rb, line 42 def self.collection @@saved end
find_by_title(title)
click to toggle source
# File lib/nyt_cli/book.rb, line 46 def self.find_by_title(title) @@all.find do |book| if book.title == title book end end end
new(hash)
click to toggle source
Initializes book with only specified keys of a hash– possibly add where to buy later
# File lib/nyt_cli/book.rb, line 10 def initialize(hash) @title = title @author = author # @description = description hash.each do |key,value| if key == "title" self.send(("#{key}="), value) elsif key == "rank" self.send(("#{key}="), value) elsif key == "author" self.send(("#{key}="), value) elsif key == "description" self.send(("#{key}="), value) elsif key == "buy_links" self.send(("#{key}="), value) end end save end
reset!()
click to toggle source
# File lib/nyt_cli/book.rb, line 54 def self.reset! @@all.clear end
Public Instance Methods
save()
click to toggle source
# File lib/nyt_cli/book.rb, line 30 def save @@all << self end