Class: Library::Book
- Inherits:
-
Object
- Object
- Library::Book
- Defined in:
- lib/library/book.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
Instance Method Summary collapse
- #checkout ⇒ Object
-
#initialize(name, author, isbn) ⇒ Book
constructor
A new instance of Book.
- #show_book_details ⇒ Object
Constructor Details
#initialize(name, author, isbn) ⇒ Book
Returns a new instance of Book.
6 7 8 9 10 11 |
# File 'lib/library/book.rb', line 6 def initialize(name, , isbn) @name = name.split.map(&:capitalize).join(' ') = .split.map(&:capitalize).join(' ') @isbn = isbn @status = true end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
3 4 5 |
# File 'lib/library/book.rb', line 3 def name @name end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
4 5 6 |
# File 'lib/library/book.rb', line 4 def status @status end |
Instance Method Details
#checkout ⇒ Object
18 19 20 |
# File 'lib/library/book.rb', line 18 def checkout @status = false end |
#show_book_details ⇒ Object
13 14 15 16 |
# File 'lib/library/book.rb', line 13 def show_book_details have_it = @status ? "available" : "not available" "#{@name} (ISBN: #{@isbn}) by #{@author} - (#{have_it})" end |