Sha256: ed6de534a62160e6fb336a8833ce3a8b015bd17f3219936668e9f75b43635dbf

Contents?: true

Size: 973 Bytes

Versions: 1

Compression:

Stored size: 973 Bytes

Contents

module Kosher

  # A book.
  #
  # A book is sold on many venues and has many offers through those venues.
  class Book < Structure
    key      :asin
    key      :edition
    key      :format
    key      :images,       :type => Hash
    key      :isbn
    key      :pages,        :type => Integer
    key      :published_in, :type => Integer
    key      :publisher
    key      :title
    key      :volumes,      :type => Integer
    has_many :alternate_versions
    has_many :authors
    has_many :offers
    has_many :related_items

    # The best kosher offer.
    #
    # Returns nil if there are no (kosher) offers.
    def best_kosher_offer
      offer = offers.sort.first
      offer && offer.kosher? ? offer : nil
    end

    # A full bibliographic description of the book, as in:
    #
    #   Chronicle Books, 1991. Hardcover. 1st edition. 2 volumes. 1200 pages.
    #
    # Missing attributes are omitted.
    def description
      # TODO
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
kosher-0.4.0 lib/kosher/book.rb