Class: Heisencoin::Offer
- Inherits:
-
Object
- Object
- Heisencoin::Offer
- Defined in:
- lib/heisencoin/offer.rb
Instance Attribute Summary collapse
-
#exchange ⇒ Object
Returns the value of attribute exchange.
-
#price ⇒ Object
Returns the value of attribute price.
-
#quantity ⇒ Object
Returns the value of attribute quantity.
Class Method Summary collapse
Instance Method Summary collapse
- #==(other) ⇒ Object
- #cost(quantity) ⇒ Object
- #from_simple(simple) ⇒ Object
-
#initialize(simple = nil) ⇒ Offer
constructor
A new instance of Offer.
- #to_simple ⇒ Object
Constructor Details
#initialize(simple = nil) ⇒ Offer
Returns a new instance of Offer.
5 6 7 |
# File 'lib/heisencoin/offer.rb', line 5 def initialize(simple = nil) from_simple(simple) if simple end |
Instance Attribute Details
#exchange ⇒ Object
Returns the value of attribute exchange.
3 4 5 |
# File 'lib/heisencoin/offer.rb', line 3 def exchange @exchange end |
#price ⇒ Object
Returns the value of attribute price.
3 4 5 |
# File 'lib/heisencoin/offer.rb', line 3 def price @price end |
#quantity ⇒ Object
Returns the value of attribute quantity.
3 4 5 |
# File 'lib/heisencoin/offer.rb', line 3 def quantity @quantity end |
Class Method Details
Instance Method Details
#==(other) ⇒ Object
21 22 23 24 25 |
# File 'lib/heisencoin/offer.rb', line 21 def ==(other) exchange.name == other.exchange.name price == other.price quantity = other.quantity end |
#cost(quantity) ⇒ Object
27 28 29 |
# File 'lib/heisencoin/offer.rb', line 27 def cost(quantity) quantity * price end |
#from_simple(simple) ⇒ Object
9 10 11 12 13 |
# File 'lib/heisencoin/offer.rb', line 9 def from_simple(simple) @exchange = Exchange.new(simple['exchange']) @price = simple['price'] @quantity = simple['quantity'] end |
#to_simple ⇒ Object
15 16 17 18 19 |
# File 'lib/heisencoin/offer.rb', line 15 def to_simple {'exchange' => exchange.to_simple, 'price' => price, 'quantity' => quantity} end |