Sha256: dcb8d0917eb6e310364a6f5a8d1f30c140e8ad256c229610c3119fdfbec9bbae
Contents?: true
Size: 812 Bytes
Versions: 2
Compression:
Stored size: 812 Bytes
Contents
module Kosher # An offer. class Offer < Structure include Comparable key :id has_one :venue has_one :item has_one :seller has_one :shipping # 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.to_money + shipping.cost.to_money end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
kosher-0.8.0 | lib/kosher/offer.rb |
kosher-0.7.0 | lib/kosher/offer.rb |