Class: Devilicious::Offer

Inherits:
Object
  • Object
show all
Defined in:
lib/devilicious/offer.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(hash) ⇒ Offer

Returns a new instance of Offer.

Raises:

  • (ArgumentError)


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

#priceObject

Returns the value of attribute price.



5
6
7
# File 'lib/devilicious/offer.rb', line 5

def price
  @price
end

#volumeObject

Returns the value of attribute volume.



5
6
7
# File 'lib/devilicious/offer.rb', line 5

def volume
  @volume
end

#weighted_priceObject

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

#inspectObject



16
17
18
# File 'lib/devilicious/offer.rb', line 16

def inspect
  "#<Devilicious::Offer price=#{price} volume=#{volume.to_f}>"
end