class BookReleasesCliApp::Book

Attributes

author[RW]
detail_author[RW]
detail_title[RW]
overview[RW]
price[RW]
release_date[RW]
store[RW]
title[RW]
type[RW]
url[RW]

Public Class Methods

all() click to toggle source
# File lib/book_releases_cli_app/book.rb, line 26
def self.all
  @@all
end
create_from_book_collection(store, books_array) click to toggle source
# File lib/book_releases_cli_app/book.rb, line 14
def self.create_from_book_collection(store, books_array)
  books = books_array.collect do |book_hash|
    book = self.new(store, book_hash)
    book.save
    book
  end
end
new(store, attributes) click to toggle source
# File lib/book_releases_cli_app/book.rb, line 6
def initialize(store, attributes)
  @store = store

  attributes.each do |attribute_name, attribute_value|
    self.send("#{attribute_name}=", attribute_value)
  end
end
print_all() click to toggle source

Public Instance Methods

save() click to toggle source
# File lib/book_releases_cli_app/book.rb, line 22
def save
  @@all << self
end
store=(store) click to toggle source
# File lib/book_releases_cli_app/book.rb, line 30
def store=(store)
  # Assign that store to myself
  #binding.pry
  @store = store

  # Creates a reciprocal belongs to
  # Tell the store that it has a new book (self)
  store.add_book(self)
end