Class: Kitchen::Directions::BakeNumberedNotes::V1
- Defined in:
- lib/kitchen/directions/bake_notes/bake_numbered_notes/v1.rb
Instance Method Summary collapse
Instance Method Details
#bake(book:, classes:, options:) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/kitchen/directions/bake_notes/bake_numbered_notes/v1.rb', line 6 def bake(book:, classes:, options:) classes.each do |klass| book.chapters.pages.notes("$.#{klass}").each do |note| chapter_count = note.ancestor(:chapter).count_in(:book) note_count = note.count_in(:chapter) bake_note(note: note, number: "#{chapter_count}.#{note_count}", options: ) end book.pages('$.appendix').notes("$.#{klass}").each do |note| appendix_count = [*('A'..'Z')][note.ancestor(:page).count_in(:book) - 1] note_count = note.count_in(:page) bake_note(note: note, number: "#{appendix_count}#{note_count}", options: ) end end end |
#bake_note(note:, number:, options:) ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/kitchen/directions/bake_notes/bake_numbered_notes/v1.rb', line 30 def bake_note(note:, number:, options:) note.wrap_children(class: 'os-note-body') note.prepend(child: <<~HTML <h3 class="os-title"> <span class="os-title-label">#{note.autogenerated_title}</span> <span class="os-number">#{number}</span> <span class="os-divider"> </span> </h3> HTML ) BakeNoteSubtitle.v1(note: note, cases: [:cases]) if note['use-subtitle'] return unless [:bake_exercises] note.exercises.each do |exercise| BakeNoteExercise.v1(note: note, exercise: exercise) end note.injected_exercises.each do |injected_exercise| BakeInjectedExercise.v1(exercise: injected_exercise) end note.injected_questions.each do |question| BakeNoteInjectedQuestion.v1(note: note, question: question) end end |