class Alexandria::Book

Constants

DEFAULT_RATING
MAX_RATING_STARS
VALID_RATINGS

Attributes

authors[RW]
edition[RW]
isbn[RW]
library[RW]
loaned[RW]
loaned_since[RW]
loaned_to[RW]
notes[RW]
own[RW]
publisher[RW]
publishing_year[RW]
rating[R]
redd[RW]
redd_when[RW]
saved_ident[RW]
tags[RW]
title[RW]
version[RW]
want[RW]

Public Class Methods

new(title, authors, isbn, publisher, publishing_year, edition) click to toggle source
# File lib/alexandria/models/book.rb, line 20
def initialize(title, authors, isbn, publisher, publishing_year,
               edition)

  @title = title
  @authors = 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

Public Instance Methods

==(other) click to toggle source
# File lib/alexandria/models/book.rb, line 67
def ==(other)
  other.is_a?(self.class) && (ident == other.ident)
end
ident() click to toggle source
# File lib/alexandria/models/book.rb, line 40
def ident
  @isbn = nil if !@isbn.nil? && @isbn.empty?
  @isbn || @title.hash.to_s
end
inspect() click to toggle source
# File lib/alexandria/models/book.rb, line 71
def inspect
  "#<Alexandria::Book title: #{@title}>"
end
loaned?() click to toggle source
# File lib/alexandria/models/book.rb, line 51
def loaned?
  loaned || false
end
own?() click to toggle source
# File lib/alexandria/models/book.rb, line 63
def own?
  own || false
end
rating=(rating) click to toggle source
# File lib/alexandria/models/book.rb, line 45
def rating=(rating)
  raise ArgumentError unless VALID_RATINGS.include? rating

  @rating = rating
end
redd?() click to toggle source
# File lib/alexandria/models/book.rb, line 55
def redd?
  redd || false
end
want?() click to toggle source
# File lib/alexandria/models/book.rb, line 59
def want?
  want || false
end