#initialize result="" sqft=0 totalf=0.0 evesf=0.0 #for each roof plane $tree["roofplanes"].keys.each_with_index do |key,index| s= index.to_s #concatenate all information evesf= $tree["roofplanes"][key]['evesf'].round(0) totalf += evesf result += ("Plane: " + s +"\t" + $tree["roofplanes"][key]['pitch'] + " \t" + $tree["roofplanes"][key]["area"].round(0).to_s + " sq ft \t" + evesf.to_s + "\n") #sum the sqft sqft +=$tree["roofplanes"][key]["area"].round(0) end #append the total result += "Total: " + sqft.to_s + "sq ft\t fascia: " + totalf.to_s + "\n" result