Class: Book
- Inherits:
-
Object
- Object
- Book
- Defined in:
- lib/book.rb
Overview
Book: contains info like title and creator also contains an array of chapters (Chapter class)
Instance Attribute Summary collapse
-
#chapters ⇒ Object
Returns the value of attribute chapters.
-
#creator ⇒ Object
Returns the value of attribute creator.
-
#isbn ⇒ Object
Returns the value of attribute isbn.
-
#pub_date ⇒ Object
Returns the value of attribute pub_date.
-
#pub_year ⇒ Object
Returns the value of attribute pub_year.
-
#title ⇒ Object
Returns the value of attribute title.
Instance Method Summary collapse
- #book_id ⇒ Object
- #cc_url ⇒ Object
-
#initialize(title, creator, pub_date = Date.today, isbn = nil) ⇒ Book
constructor
A new instance of Book.
Constructor Details
#initialize(title, creator, pub_date = Date.today, isbn = nil) ⇒ Book
Returns a new instance of Book.
7 8 9 10 11 12 |
# File 'lib/book.rb', line 7 def initialize(title, creator, pub_date = Date.today, isbn = nil) self.title = title self.creator = creator self.pub_date = pub_date self.isbn = isbn end |
Instance Attribute Details
#chapters ⇒ Object
Returns the value of attribute chapters.
4 5 6 |
# File 'lib/book.rb', line 4 def chapters @chapters end |
#creator ⇒ Object
Returns the value of attribute creator.
4 5 6 |
# File 'lib/book.rb', line 4 def creator @creator end |
#isbn ⇒ Object
Returns the value of attribute isbn.
4 5 6 |
# File 'lib/book.rb', line 4 def isbn @isbn end |
#pub_date ⇒ Object
Returns the value of attribute pub_date.
4 5 6 |
# File 'lib/book.rb', line 4 def pub_date @pub_date end |
#pub_year ⇒ Object
Returns the value of attribute pub_year.
4 5 6 |
# File 'lib/book.rb', line 4 def pub_year @pub_year end |
#title ⇒ Object
Returns the value of attribute title.
4 5 6 |
# File 'lib/book.rb', line 4 def title @title end |
Instance Method Details
#book_id ⇒ Object
14 15 16 |
# File 'lib/book.rb', line 14 def book_id @book_id ||= (isbn || "urn:uuid:#{UUID.new.generate}") end |
#cc_url ⇒ Object
22 23 24 25 26 27 28 |
# File 'lib/book.rb', line 22 def cc_url # attribution only, free to distribute, modify, or use commercially: # "http://creativecommons.org/licenses/by/3.0/" # free to share with attribution, non-commercial, no derivatives "http://creativecommons.org/licenses/by-nc-nd/3.0/" end |