-1
Вот мой стол, как я могу суммировать поля цены и qty в нижней части таблицы?Как суммировать столбцы в Ruby
def output_action_header(text)
puts "\n#{text.upcase.center(60)}\n\n"
end
def output_stock_table(stock=[])
print " " + "Stock Type".ljust(30)
print " " + "Number".ljust(20)
print " " + "Transaction".ljust(20)
print " " + "Price".rjust(6) + "\n"
puts "-" * 90
stock.each do |rest|
line = " " << rest.name.titleize.ljust(30)
line << " " + rest.qty.titleize.ljust(20)
line << " " + rest.transaction.titleize.ljust(20)
line << " " + rest.formatted_price.rjust(6)
puts line
end
puts "-" * 90
end
Что такое запасы, похоже на входящие в функцию? – Anthony