Sha256: 6ff169408b78d6058869e90dfe0a988249a565836ac01a0bd83f5a0376f75958
Contents?: true
Size: 616 Bytes
Versions: 3
Compression:
Stored size: 616 Bytes
Contents
module Kosher class Offer < Struct.new(:id, :url, :item, :seller, :shipping) include Comparable def <=>(other) if self.kosher? != other.kosher? self.kosher? ? -1 : 1 else currency = base_currency self.price.exchange_to(currency) <=> other.price.exchange_to(currency) end end def base_currency @base_currency ||= 'EUR' end def base_currency=(currency) @base_currency = currency end def kosher? item.kosher? && seller.kosher? && shipping.kosher? end def price item.price + shipping.cost end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
kosher-0.2.6 | lib/kosher/offer.rb |
kosher-0.2.5 | lib/kosher/offer.rb |
kosher-0.2.4 | lib/kosher/offer.rb |