I'm trying to create a function to complete the sequence of hours in the following hash.
{
name: "cardio",
data: [["06:00", 999], ["09:00", 154], ["10:00", 1059], ["11:00", 90]]
}
It should create all the missing values in the field data
["07:00", 0], ["08:00", 0], ["12:00", 0], ["13:00", 0] ... ["23:00", 0]
Expected result:
{
name: "cardio",
data: [["06:00", 999], ["07:00", 0], ["08:00", 0], ["09:00", 154], ["10:00", 1059], ["11:00", 90]], ["12:00", 0], ["13:00", 0] ... ["23:00", 0]
}
Is it possible to do that? Something like:
data.each do |row|
(6..23).each do |hour|
.....
end
end