Class: NotableBooks2018::Book

Inherits:
Object
  • Object
show all
Defined in:
lib/notable_books_2018/book.rb

Constant Summary collapse

@@all =
[]

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(book_hash) ⇒ Book

Returns a new instance of Book.



12
13
14
15
16
17
# File 'lib/notable_books_2018/book.rb', line 12

def initialize(book_hash)
  book_hash.each do |attribute, value|
    self.send("#{attribute}=", value)
  end
  @@all << self
end

Instance Attribute Details

#authorObject

Returns the value of attribute author.



5
6
7
# File 'lib/notable_books_2018/book.rb', line 5

def author
  @author
end

#descriptionObject

Returns the value of attribute description.



5
6
7
# File 'lib/notable_books_2018/book.rb', line 5

def description
  @description
end

#genreObject

Returns the value of attribute genre.



6
7
8
# File 'lib/notable_books_2018/book.rb', line 6

def genre
  @genre
end

#priceObject

Returns the value of attribute price.



5
6
7
# File 'lib/notable_books_2018/book.rb', line 5

def price
  @price
end

#publisherObject

Returns the value of attribute publisher.



5
6
7
# File 'lib/notable_books_2018/book.rb', line 5

def publisher
  @publisher
end

#titleObject

Returns the value of attribute title.



5
6
7
# File 'lib/notable_books_2018/book.rb', line 5

def title
  @title
end

Class Method Details

.allObject



8
9
10
# File 'lib/notable_books_2018/book.rb', line 8

def self.all
  @@all
end

.create_from_collection(book_array) ⇒ Object



26
27
28
29
30
# File 'lib/notable_books_2018/book.rb', line 26

def self.create_from_collection(book_array)
  book_array.each do |book_hash|
    NotableBooks2018::Book.new(book_hash)
  end
end