Class: DayBooks::Book
- Inherits:
-
Object
- Object
- DayBooks::Book
- Defined in:
- lib/book.rb
Constant Summary collapse
- @@all =
[]
- @@all_titles =
[]
Instance Attribute Summary collapse
-
#all_titles ⇒ Object
Returns the value of attribute all_titles.
-
#book_url ⇒ Object
Returns the value of attribute book_url.
-
#title ⇒ Object
Returns the value of attribute title.
Class Method Summary collapse
- .all ⇒ Object
- .all_titles ⇒ Object
- .create(title, book_url) ⇒ Object
- .downcase_all_titles ⇒ Object
- .empty_all ⇒ Object
Instance Method Summary collapse
-
#initialize(title = nil, book_url = nil) ⇒ Book
constructor
A new instance of Book.
- #save ⇒ Object
Constructor Details
#initialize(title = nil, book_url = nil) ⇒ Book
Returns a new instance of Book.
8 9 10 11 |
# File 'lib/book.rb', line 8 def initialize(title = nil, book_url = nil) @title = title @book_url = book_url end |
Instance Attribute Details
#all_titles ⇒ Object
Returns the value of attribute all_titles.
4 5 6 |
# File 'lib/book.rb', line 4 def all_titles @all_titles end |
#book_url ⇒ Object
Returns the value of attribute book_url.
4 5 6 |
# File 'lib/book.rb', line 4 def book_url @book_url end |
#title ⇒ Object
Returns the value of attribute title.
4 5 6 |
# File 'lib/book.rb', line 4 def title @title end |
Class Method Details
.all ⇒ Object
13 14 15 |
# File 'lib/book.rb', line 13 def self.all @@all end |
.all_titles ⇒ Object
17 18 19 |
# File 'lib/book.rb', line 17 def self.all_titles @@all_titles end |
.create(title, book_url) ⇒ Object
35 36 37 38 39 |
# File 'lib/book.rb', line 35 def self.create(title, book_url) new_book = self.new(title, book_url) new_book.save new_book end |
.downcase_all_titles ⇒ Object
31 32 33 |
# File 'lib/book.rb', line 31 def self.downcase_all_titles @@all_titles.map {|title| title.downcase} end |
.empty_all ⇒ Object
26 27 28 29 |
# File 'lib/book.rb', line 26 def self.empty_all @@all.clear @@all_titles.clear end |
Instance Method Details
#save ⇒ Object
21 22 23 24 |
# File 'lib/book.rb', line 21 def save @@all << self @@all_titles << @title end |