这是我的报告控制器中的代码,它看起来很糟糕,谁能给我一些关于如何整理它的建议?
# app\controller\reports_controller.rb
@report_lines = []
@sum_wp, @sum_projcted_wp, @sum_il, @sum_projcted_il, @sum_li,@sum_gross_profit ,@sum_opportunities = [0,0,0,0,0,0,0]
date = @start_date
num_of_months.times do
wp,projected_wp, invoice_line,projected_il,line_item, opp = Report.data_of_invoicing_and_delivery_report(@part_or_service,date)
@sum_wp += wp
@sum_projcted_wp +=projected_wp
@sum_il=invoice_line
@sum_projcted_il +=projected_il
@sum_li += line_item
gross_profit = invoice_line - line_item
@sum_gross_profit += gross_profit
@sum_opportunities += opp
@report_lines << [date.strftime("%m/%Y"),wp,projected_wp ,invoice_line,projected_il,line_item,gross_profit,opp]
date = date.next_month
end
我正在寻找使用某种方法,例如
@sum_a,@sum_b,@sum_c += [1,2,3]