Class: Kitchen::Directions::BakeNumberedNotes::V2

Inherits:
Object
  • Object
show all
Defined in:
lib/kitchen/directions/bake_notes/bake_numbered_notes/v2.rb

Instance Method Summary collapse

Instance Method Details

#bake(book:, classes:) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/kitchen/directions/bake_notes/bake_numbered_notes/v2.rb', line 6

def bake(book:, classes:)
  classes.each do |klass|
    book.chapters.pages.notes("$.#{klass}").each do |note|
      note.wrap_children(class: 'os-note-body')
      note_count = note.count_in(:page)
      note.prepend(child:
        <<~HTML
          <h3 class="os-title">
            <span class="os-title-label">#{note.autogenerated_title}</span>
            <span class="os-number">##{note_count}</span>
          </h3>
        HTML
      )
      note.exercises.each do |exercise|
        BakeNoteExercise.v1(note: note, exercise: exercise, divider: '. ')
      end
      note.injected_questions.each do |question|
        BakeNoteInjectedQuestion.v1(note: note, question: question)
      end
    end
  end
end