Sha256: dffd3797d83dd68a2042e1c75cf7dd0073fc527a491ca3347b65ed3389a325c8
Contents?: true
Size: 908 Bytes
Versions: 3
Compression:
Stored size: 908 Bytes
Contents
module Kosher # An offer. # # This is an actual item offered on a particular venue by a seller. class Offer < Structure include Comparable key :id key :venue key :item, :type => Structure key :seller, :type => Structure key :shipping, :type => Structure # Compares offer with another offer. # # A kosher offer is better than an unkosher offer. If both offers are # kosher or unkosher, a lower-priced offer is better. def <=>(other) if kosher? != other.kosher? kosher? ? -1 : 1 else price <=> other.price end end # Returns whether the offer is kosher. # # An offer is kosher if its item, seller, and shipping are kosher. def kosher? item.kosher? && seller.kosher? && shipping.kosher? end # The total price of an offer. def price item.price + shipping.cost end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
kosher-0.5.0 | lib/kosher/offer.rb |
kosher-0.4.0 | lib/kosher/offer.rb |
kosher-0.3.0 | lib/kosher/offer.rb |