Class: Libri::Books
- Inherits:
-
Object
- Object
- Libri::Books
- Defined in:
- lib/libri/books.rb
Constant Summary collapse
- @@all =
[]
Instance Attribute Summary collapse
-
#author ⇒ Object
Returns the value of attribute author.
-
#title ⇒ Object
Returns the value of attribute title.
-
#url ⇒ Object
Returns the value of attribute url.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(books_hash) ⇒ Books
constructor
A new instance of Books.
Constructor Details
#initialize(books_hash) ⇒ Books
Returns a new instance of Books.
6 7 8 9 10 11 |
# File 'lib/libri/books.rb', line 6 def initialize(books_hash) books_hash.map { |key, val| send "#{key}=", val } @@all << self end |
Instance Attribute Details
#author ⇒ Object
Returns the value of attribute author.
2 3 4 |
# File 'lib/libri/books.rb', line 2 def @author end |
#title ⇒ Object
Returns the value of attribute title.
2 3 4 |
# File 'lib/libri/books.rb', line 2 def title @title end |
#url ⇒ Object
Returns the value of attribute url.
2 3 4 |
# File 'lib/libri/books.rb', line 2 def url @url end |
Class Method Details
.all ⇒ Object
19 20 21 |
# File 'lib/libri/books.rb', line 19 def self.all @@all end |
.create_from_collection(books_array) ⇒ Object
13 14 15 16 17 |
# File 'lib/libri/books.rb', line 13 def self.create_from_collection(books_array) books_array.map { |books_hash| self.new(books_hash) } end |