Class: Library::Book

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

Instance Attribute Summary collapse

Instance Method Summary collapse

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, author, isbn)
  @name = name.split.map(&:capitalize).join(' ')
  @author = author.split.map(&:capitalize).join(' ')
  @isbn = isbn
  @status = true
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



3
4
5
# File 'lib/library/book.rb', line 3

def name
  @name
end

#statusObject (readonly)

Returns the value of attribute status.



4
5
6
# File 'lib/library/book.rb', line 4

def status
  @status
end

Instance Method Details

#checkoutObject



18
19
20
# File 'lib/library/book.rb', line 18

def checkout
  @status = false
end

#show_book_detailsObject



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