Class: BookReleasesCliApp::Book
- Inherits:
-
Object
- Object
- BookReleasesCliApp::Book
- Defined in:
- lib/book_releases_cli_app/book.rb
Constant Summary collapse
- @@all =
[]
Instance Attribute Summary collapse
-
#author ⇒ Object
Returns the value of attribute author.
-
#detail_author ⇒ Object
Returns the value of attribute detail_author.
-
#detail_title ⇒ Object
Returns the value of attribute detail_title.
-
#overview ⇒ Object
Returns the value of attribute overview.
-
#price ⇒ Object
Returns the value of attribute price.
-
#release_date ⇒ Object
Returns the value of attribute release_date.
-
#store ⇒ Object
Returns the value of attribute store.
-
#title ⇒ Object
Returns the value of attribute title.
-
#type ⇒ Object
Returns the value of attribute type.
-
#url ⇒ Object
Returns the value of attribute url.
Class Method Summary collapse
-
.all ⇒ Object
save instance –.
-
.create_from_book_collection(store, books_array) ⇒ Object
– initialize –.
-
.print_all ⇒ Object
– store writter –.
Instance Method Summary collapse
-
#initialize(store, attributes) ⇒ Book
constructor
A new instance of Book.
-
#save ⇒ Object
– self.create_from_book_collection –.
Constructor Details
#initialize(store, attributes) ⇒ Book
Returns a new instance of Book.
6 7 8 9 10 11 12 |
# 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 |
Instance Attribute Details
#author ⇒ Object
Returns the value of attribute author.
2 3 4 |
# File 'lib/book_releases_cli_app/book.rb', line 2 def @author end |
#detail_author ⇒ Object
Returns the value of attribute detail_author.
2 3 4 |
# File 'lib/book_releases_cli_app/book.rb', line 2 def @detail_author end |
#detail_title ⇒ Object
Returns the value of attribute detail_title.
2 3 4 |
# File 'lib/book_releases_cli_app/book.rb', line 2 def detail_title @detail_title end |
#overview ⇒ Object
Returns the value of attribute overview.
2 3 4 |
# File 'lib/book_releases_cli_app/book.rb', line 2 def overview @overview end |
#price ⇒ Object
Returns the value of attribute price.
2 3 4 |
# File 'lib/book_releases_cli_app/book.rb', line 2 def price @price end |
#release_date ⇒ Object
Returns the value of attribute release_date.
2 3 4 |
# File 'lib/book_releases_cli_app/book.rb', line 2 def release_date @release_date end |
#store ⇒ Object
Returns the value of attribute store.
2 3 4 |
# File 'lib/book_releases_cli_app/book.rb', line 2 def store @store end |
#title ⇒ Object
Returns the value of attribute title.
2 3 4 |
# File 'lib/book_releases_cli_app/book.rb', line 2 def title @title end |
#type ⇒ Object
Returns the value of attribute type.
2 3 4 |
# File 'lib/book_releases_cli_app/book.rb', line 2 def type @type end |
#url ⇒ Object
Returns the value of attribute url.
2 3 4 |
# File 'lib/book_releases_cli_app/book.rb', line 2 def url @url end |
Class Method Details
.all ⇒ Object
save instance –
26 27 28 |
# File 'lib/book_releases_cli_app/book.rb', line 26 def self.all @@all end |
.create_from_book_collection(store, books_array) ⇒ Object
– initialize –
14 15 16 17 18 19 20 |
# 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 |
.print_all ⇒ Object
– store writter –
40 41 42 43 44 |
# File 'lib/book_releases_cli_app/book.rb', line 40 def self.print_all all.each.with_index(1) do |book, index| puts "[#{index}]. #{book.title} - #{book.} - #{book.release_date} - #{book.type} #{book.price}" end end |
Instance Method Details
#save ⇒ Object
– self.create_from_book_collection –
22 23 24 |
# File 'lib/book_releases_cli_app/book.rb', line 22 def save @@all << self end |