Hi,
Anyone can help me on how to layout my output? See my source code;
Start Here
report = Hash.new
PTable.all(:conditions => [‘status = “success” AND created_at >= ? AND
created_at < ?’, Date.today.midnight, Date.today.midnight +
1.day]).inject(0) { |total, p_table|
unless translations.flatten.any? {|t| t == p_table.id || t ==
pt.rd_field}
evalsum = eval(p_table.rd_field) if !p_table.rd_field.nil?
norm = evalsum[:ctms].inject(0) {|sum, room| sum + norm.length}
nopn = evalsum[:ctms].length
if report[evalsum[:hname]].nil?
report.store(evalsum[:hname], {'norm' => norm, 'nopn' => nopn})
else
report[evalsum[:hname]]['norm'] += norm
report[evalsum[:hname]]['nopn'] += nopn
end
end
}
puts report.inspect
}
end
End Here
Here are the Output of my code;
{“AAA”=>{“nopn”=>2, “norm”=>4}, “BBB”=>{“nopn”=>1, “norm”=>2},
“CCC”=>{“nopn”=>1, “norm”=>2}, “DDD”=>{“nopn”=>1, “norm”=>2},
“EEE”=>{“nopn”=>5, “norm”=>10}, “FFF”=>{“nopn”=>1, “norm”=>2},
“GGG”=>{“nopn”=>4, “norm”=>8}, “HHH”=>{“nopn”=>1, “norm”=>2},
“III”=>{“nopn”=>1, “norm”=>2}, “JJJ”=>{“nopn”=>1, “norm”=>2},
“KKK”=>{“nopn”=>1, “norm”=>2}, “LLL”=>{“nopn”=>1, “norm”=>2},
“MMM”=>{“nopn”=>2, “norm”=>4}}
How can I do these Output Layout I need like belows;
AAA 2 4
BBB 1 2
CCC 1 2
DDD 1 2
EEE 5 10
FFF 1 2
GGG 4 8
HHH 1 2
III 1 2
JJJ 1 2
KKK 1 2
LLL 1 2
MMM 2 4
Thanks in Advance!