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.
164 165 166 167 168 169 |
# File 'lib/oolite/trade.rb', line 164 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.
160 161 162 |
# File 'lib/oolite/trade.rb', line 160 def amount @amount end |
#cost ⇒ Object
Returns the value of attribute cost.
161 162 163 |
# File 'lib/oolite/trade.rb', line 161 def cost @cost end |
#name ⇒ Object
Returns the value of attribute name.
159 160 161 |
# File 'lib/oolite/trade.rb', line 159 def name @name end |
#revenue ⇒ Object
Returns the value of attribute revenue.
162 163 164 |
# File 'lib/oolite/trade.rb', line 162 def revenue @revenue end |
Instance Method Details
#to_s ⇒ Object
171 172 173 |
# File 'lib/oolite/trade.rb', line 171 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 |