I suppose you could use Enumerable#inject :
plans.each do |plan| total = [:landline, :vpn, :other_networks, :gprs, :sms, :mms, :internat_calls_zone_1, :internat_calls_zone_2].inject(0) { |t, method| t + plan.send(method).to_f * @landline.send(method).to_f } if total < @total @total = total @plan_new = plan end end
source share