Class: Book

Inherits:
Library show all
Defined in:
lib/book.rb

Instance Attribute Summary collapse

Attributes inherited from Library

#authors, #books, #orders, #readers

Instance Method Summary collapse

Methods inherited from Library

#find_author, #find_book, #find_reader, #save_resource

Methods included from LibraryBackupManager

#as_yaml, included, #save_backup

Constructor Details

#initialize(title, author) ⇒ Book

Returns a new instance of Book.



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

def initialize(title, author)
  @title = title
  @author = author
end

Instance Attribute Details

#authorObject

Returns the value of attribute author.



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

def author
  @author
end

#titleObject

Returns the value of attribute title.



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

def title
  @title
end

Instance Method Details

#to_hObject



9
10
11
12
13
14
# File 'lib/book.rb', line 9

def to_h
  {
    title: title,
    author: author.name
  }
end