Class: Alexandria::Book
- Inherits:
-
Object
- Object
- Alexandria::Book
- Defined in:
- lib/alexandria/models/book.rb
Constant Summary collapse
- DEFAULT_RATING =
0
- MAX_RATING_STARS =
5
- VALID_RATINGS =
(DEFAULT_RATING..MAX_RATING_STARS).freeze
Instance Attribute Summary collapse
-
#authors ⇒ Object
Returns the value of attribute authors.
-
#edition ⇒ Object
Returns the value of attribute edition.
-
#isbn ⇒ Object
Returns the value of attribute isbn.
-
#library ⇒ Object
Returns the value of attribute library.
-
#loaned ⇒ Object
Returns the value of attribute loaned.
-
#loaned_since ⇒ Object
Returns the value of attribute loaned_since.
-
#loaned_to ⇒ Object
Returns the value of attribute loaned_to.
-
#notes ⇒ Object
Returns the value of attribute notes.
-
#own ⇒ Object
Returns the value of attribute own.
-
#publisher ⇒ Object
Returns the value of attribute publisher.
-
#publishing_year ⇒ Object
Returns the value of attribute publishing_year.
-
#rating ⇒ Object
Returns the value of attribute rating.
-
#redd ⇒ Object
Returns the value of attribute redd.
-
#redd_when ⇒ Object
Returns the value of attribute redd_when.
-
#saved_ident ⇒ Object
Returns the value of attribute saved_ident.
-
#tags ⇒ Object
Returns the value of attribute tags.
-
#title ⇒ Object
Returns the value of attribute title.
-
#version ⇒ Object
Returns the value of attribute version.
-
#want ⇒ Object
Returns the value of attribute want.
Instance Method Summary collapse
- #==(other) ⇒ Object
- #ident ⇒ Object
-
#initialize(title, authors, isbn, publisher, publishing_year, edition) ⇒ Book
constructor
A new instance of Book.
- #inspect ⇒ Object
- #loaned? ⇒ Boolean
- #own? ⇒ Boolean
- #redd? ⇒ Boolean
- #want? ⇒ Boolean
Constructor Details
#initialize(title, authors, isbn, publisher, publishing_year, edition) ⇒ Book
Returns a new instance of Book.
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/alexandria/models/book.rb', line 20 def initialize(title, , isbn, publisher, publishing_year, edition) @title = title @authors = @isbn = isbn @publisher = publisher @edition = edition # actually used for binding! (i.e. paperback or hardback) @notes = "" @saved_ident = ident @publishing_year = publishing_year @redd = false @own = true @want = true @tags = [] @rating = DEFAULT_RATING # Need to implement bulk save function to update this @version = Alexandria::DATA_VERSION end |
Instance Attribute Details
#authors ⇒ Object
Returns the value of attribute authors.
9 10 11 |
# File 'lib/alexandria/models/book.rb', line 9 def @authors end |
#edition ⇒ Object
Returns the value of attribute edition.
9 10 11 |
# File 'lib/alexandria/models/book.rb', line 9 def edition @edition end |
#isbn ⇒ Object
Returns the value of attribute isbn.
9 10 11 |
# File 'lib/alexandria/models/book.rb', line 9 def isbn @isbn end |
#library ⇒ Object
Returns the value of attribute library.
9 10 11 |
# File 'lib/alexandria/models/book.rb', line 9 def library @library end |
#loaned ⇒ Object
Returns the value of attribute loaned.
9 10 11 |
# File 'lib/alexandria/models/book.rb', line 9 def loaned @loaned end |
#loaned_since ⇒ Object
Returns the value of attribute loaned_since.
9 10 11 |
# File 'lib/alexandria/models/book.rb', line 9 def loaned_since @loaned_since end |
#loaned_to ⇒ Object
Returns the value of attribute loaned_to.
9 10 11 |
# File 'lib/alexandria/models/book.rb', line 9 def loaned_to @loaned_to end |
#notes ⇒ Object
Returns the value of attribute notes.
9 10 11 |
# File 'lib/alexandria/models/book.rb', line 9 def notes @notes end |
#own ⇒ Object
Returns the value of attribute own.
9 10 11 |
# File 'lib/alexandria/models/book.rb', line 9 def own @own end |
#publisher ⇒ Object
Returns the value of attribute publisher.
9 10 11 |
# File 'lib/alexandria/models/book.rb', line 9 def publisher @publisher end |
#publishing_year ⇒ Object
Returns the value of attribute publishing_year.
9 10 11 |
# File 'lib/alexandria/models/book.rb', line 9 def publishing_year @publishing_year end |
#rating ⇒ Object
Returns the value of attribute rating.
14 15 16 |
# File 'lib/alexandria/models/book.rb', line 14 def @rating end |
#redd ⇒ Object
Returns the value of attribute redd.
9 10 11 |
# File 'lib/alexandria/models/book.rb', line 9 def redd @redd end |
#redd_when ⇒ Object
Returns the value of attribute redd_when.
9 10 11 |
# File 'lib/alexandria/models/book.rb', line 9 def redd_when @redd_when end |
#saved_ident ⇒ Object
Returns the value of attribute saved_ident.
9 10 11 |
# File 'lib/alexandria/models/book.rb', line 9 def saved_ident @saved_ident end |
#tags ⇒ Object
Returns the value of attribute tags.
9 10 11 |
# File 'lib/alexandria/models/book.rb', line 9 def @tags end |
#title ⇒ Object
Returns the value of attribute title.
9 10 11 |
# File 'lib/alexandria/models/book.rb', line 9 def title @title end |
#version ⇒ Object
Returns the value of attribute version.
9 10 11 |
# File 'lib/alexandria/models/book.rb', line 9 def version @version end |
#want ⇒ Object
Returns the value of attribute want.
9 10 11 |
# File 'lib/alexandria/models/book.rb', line 9 def want @want end |
Instance Method Details
#==(other) ⇒ Object
67 68 69 |
# File 'lib/alexandria/models/book.rb', line 67 def ==(other) other.is_a?(self.class) && (ident == other.ident) end |
#ident ⇒ Object
40 41 42 43 |
# File 'lib/alexandria/models/book.rb', line 40 def ident @isbn = nil if !@isbn.nil? && @isbn.empty? @isbn || @title.hash.to_s end |
#inspect ⇒ Object
71 72 73 |
# File 'lib/alexandria/models/book.rb', line 71 def inspect "#<Alexandria::Book title: #{@title}>" end |
#loaned? ⇒ Boolean
51 52 53 |
# File 'lib/alexandria/models/book.rb', line 51 def loaned? loaned || false end |
#own? ⇒ Boolean
63 64 65 |
# File 'lib/alexandria/models/book.rb', line 63 def own? own || false end |
#redd? ⇒ Boolean
55 56 57 |
# File 'lib/alexandria/models/book.rb', line 55 def redd? redd || false end |
#want? ⇒ Boolean
59 60 61 |
# File 'lib/alexandria/models/book.rb', line 59 def want? want || false end |