Class: Oolite::Trade::TradeItem
- Inherits:
-
Object
- Object
- Oolite::Trade::TradeItem
- Defined in:
- lib/oolite/trade.rb
Instance Attribute Summary collapse
-
#amount ⇒ Object
Returns the value of attribute amount.
-
#cost ⇒ Object
Returns the value of attribute cost.
-
#name ⇒ Object
Returns the value of attribute name.
-
#revenue ⇒ Object
Returns the value of attribute revenue.
Instance Method Summary collapse
-
#initialize(name, amount, cost, revenue) ⇒ TradeItem
constructor
A new instance of TradeItem.
- #to_s ⇒ Object
Constructor Details
#initialize(name, amount, cost, revenue) ⇒ TradeItem
Returns a new instance of TradeItem.
99 100 101 102 103 104 |
# File 'lib/oolite/trade.rb', line 99 def initialize name, amount, cost, revenue @name = name @amount = amount @cost = cost @revenue = revenue end |
Instance Attribute Details
#amount ⇒ Object
Returns the value of attribute amount.
95 96 97 |
# File 'lib/oolite/trade.rb', line 95 def amount @amount end |
#cost ⇒ Object
Returns the value of attribute cost.
96 97 98 |
# File 'lib/oolite/trade.rb', line 96 def cost @cost end |
#name ⇒ Object
Returns the value of attribute name.
94 95 96 |
# File 'lib/oolite/trade.rb', line 94 def name @name end |
#revenue ⇒ Object
Returns the value of attribute revenue.
97 98 99 |
# File 'lib/oolite/trade.rb', line 97 def revenue @revenue end |
Instance Method Details
#to_s ⇒ Object
106 107 108 |
# File 'lib/oolite/trade.rb', line 106 def to_s "#{name.ljust(14)} #{amount.to_s.ljust(10)} #{(cost / 10.0).to_s.rjust(8)} #{(revenue / 10.0).to_s.rjust(12)}" end |