Class: Book

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(book_id, title, author_id, publisher_id) ⇒ Book

Returns a new instance of Book.



4
5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/models/book.rb', line 4

def initialize(book_id, title, author_id, publisher_id)
  validate_null('book_id', book_id)
  validate_null('title', title)
  validate_null('author_id', author_id)
  validate_null('publisher_id', publisher_id)

  validate_title_length(title)

  @book_id = book_id
  @title = title
  @author_id = author_id
  @publisher_id = publisher_id
end

Instance Attribute Details

#author_idObject (readonly)

Returns the value of attribute author_id.



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

def author_id
  @author_id
end

#book_idObject (readonly)

Returns the value of attribute book_id.



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

def book_id
  @book_id
end

#publisher_idObject (readonly)

Returns the value of attribute publisher_id.



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

def publisher_id
  @publisher_id
end

#titleObject (readonly)

Returns the value of attribute title.



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

def title
  @title
end