Class: FifoLifo::Main
- Inherits:
-
Object
- Object
- FifoLifo::Main
- Defined in:
- lib/fifo_lifo.rb
Instance Method Summary collapse
-
#display_results ⇒ Object
displays all of the result desired.
-
#initialize(bitcoins, prices) ⇒ Main
constructor
A new instance of Main.
Constructor Details
#initialize(bitcoins, prices) ⇒ Main
Returns a new instance of Main.
12 13 14 15 16 |
# File 'lib/fifo_lifo.rb', line 12 def initialize(bitcoins, prices) @utils = Utilities.new(bitcoins, prices) @fifo = Fifo.new(@utils) @lifo = Lifo.new(@utils) end |
Instance Method Details
#display_results ⇒ Object
displays all of the result desired
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/fifo_lifo.rb', line 19 def display_results fifo_gotten_results = @fifo.get_profit_or_lost_with_fifo fifo_cost_of_goods_sold = fifo_gotten_results[1] fifo_total_income = fifo_gotten_results[2] lifo_gotten_results = @lifo.get_profit_or_lost_with_lifo lifo_cost_of_goods_sold = lifo_gotten_results[1] lifo_total_income = lifo_gotten_results[2] units_purchased = @utils.get_unit_purchased units_sold = @utils.get_unit_sold final_invetory = units_purchased + units_sold puts "\n\n" puts "======= The following are the general results regardless of FIFO nor LIFO approach =======" puts "============================================================================================" puts "The final invetory is: #{final_invetory}" puts "Units sold are: #{units_sold}" puts "Units purchased are: #{units_purchased}" puts "The total cost is: #{@utils.get_total_cost}" puts "\n\n" puts "======= The following are the results gotten if we perform the FIFO approach =======" puts "======================================================================================" puts "The cost_of_goods_sold with FIFO is: #{fifo_cost_of_goods_sold}" puts "The total_income with FIFO is: #{fifo_total_income}" puts fifo_gotten_results[0] puts "\n\n" puts "======= The following are the results gotten if we perform the LIFO approach =======" puts "======================================================================================" puts "The cost_of_goods_sold with LIFO is: #{lifo_cost_of_goods_sold}" puts "The total_income with LIFO is: #{lifo_total_income}" puts lifo_gotten_results[0] puts "\n\n" end |