FILE = File.join(File.dirname(__FILE__), '..', 'activity_exercise_sport.csv')
WEIGHTS = [130, 155, 180, 205]
@@aes = {}
rows = FasterCSV.read(FILE)
header = rows.delete_at(0)
rows.each do |row|
@@aes[row[header.index("Activity, Exercise or Sport (1 hour)")]] =
weight_calory_map = {}
WEIGHTS.each do |w|
weight_calory_map.store(w, row[header.index("#{w} lb")].to_i)
end
weight_calory_map
end
Refactorings
No refactoring yet !
The part where weight_calory_map gets formed is just ugly. I'm sure there is a one liner for the same and the weight_calory_map is just not required.