File tree Expand file tree Collapse file tree 1 file changed +4
-4
lines changed Expand file tree Collapse file tree 1 file changed +4
-4
lines changed Original file line number Diff line number Diff line change @@ -31,15 +31,15 @@ def indexing_lessons(lessons : Array)
31
31
lessons.map_with_index(1 ) { |lesson , index | lesson.merge({ position: index}) }
32
32
end
33
33
34
- selected_lessons = sections.map { | section | section [:lessons ] }.flatten
34
+ selected_lessons = sections.flat_map( & . [:lessons ])
35
35
indexed_lessons = indexing_lessons(selected_lessons)
36
36
37
- formated_section = sections.map do |section |
37
+ formated_section = sections.map_with_index( 1 ) do |section , i |
38
38
formated_lessons = indexed_lessons.shift(section[:lessons ].size)
39
39
if section[:reset_lesson_position ]
40
40
formated_lessons = indexing_lessons(section[:lessons ])
41
41
end
42
- section.merge(lessons: formated_lessons)
42
+ section.merge(position: i, lessons: formated_lessons)
43
43
end
44
44
45
- p formated_section
45
+ pp formated_section
You can’t perform that action at this time.
0 commit comments