Class: Devilicious::Offer
- Inherits:
-
Object
- Object
- Devilicious::Offer
- Defined in:
- lib/devilicious/offer.rb
Instance Attribute Summary collapse
-
#price ⇒ Object
Returns the value of attribute price.
-
#volume ⇒ Object
Returns the value of attribute volume.
-
#weighted_price ⇒ Object
Returns the value of attribute weighted_price.
Instance Method Summary collapse
-
#initialize(hash) ⇒ Offer
constructor
A new instance of Offer.
- #inspect ⇒ Object
Constructor Details
#initialize(hash) ⇒ Offer
Returns a new instance of Offer.
7 8 9 10 11 12 13 14 |
# File 'lib/devilicious/offer.rb', line 7 def initialize(hash) self.price = hash.delete(:price) self.weighted_price = hash.delete(:weighted_price) self.volume = BigDecimal.new(hash.delete(:volume)) raise ArgumentError unless hash.empty? raise ArgumentError, "#{price.class} is not Money" unless price.is_a? Money end |
Instance Attribute Details
#price ⇒ Object
Returns the value of attribute price.
5 6 7 |
# File 'lib/devilicious/offer.rb', line 5 def price @price end |
#volume ⇒ Object
Returns the value of attribute volume.
5 6 7 |
# File 'lib/devilicious/offer.rb', line 5 def volume @volume end |
#weighted_price ⇒ Object
Returns the value of attribute weighted_price.
5 6 7 |
# File 'lib/devilicious/offer.rb', line 5 def weighted_price @weighted_price end |
Instance Method Details
#inspect ⇒ Object
16 17 18 |
# File 'lib/devilicious/offer.rb', line 16 def inspect "#<Devilicious::Offer price=#{price} volume=#{volume.to_f}>" end |