records =[{"delivery_income_num"=>62,
"delivery_num"=>0,
"income_fee"=>3,
"pickup_alipay_pay_num"=>0,
"pickup_wechat_pay_num"=>3,
"box_num"=>0,
}]
def sum_overview(records)
delivery_num = 0.0
income_fee = 0.0
box_num = 0.0
records.each do |record|
delivery_num = delivery_num + record[:delivery_num]
income_fee = income_fee + record[:income_fee]
box_num = box_num + record[:box_num]
end
{delivery_num: delivery_num, income_fee: income_fee, delivery_rate: delivery_num/box_num}
end
有个哈希数组,需要对数组里的每个哈希的 value 累加,有什么代码简洁而且还高效的方法 或者有没有类似处理功能的 gem 推荐