Class: Kitchen::Directions::MoveSolutionsFromNumberedNote::V1

Inherits:
Object
  • Object
show all
Defined in:
lib/kitchen/directions/move_solutions_to_answer_key/move_solutions_from_numbered_note.rb

Instance Method Summary collapse

Instance Method Details

#bake(chapter:, append_to:, note_class:) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/kitchen/directions/move_solutions_to_answer_key/move_solutions_from_numbered_note.rb', line 9

def bake(chapter:, append_to:, note_class:)
  solutions_clipboard = chapter.notes("$.#{note_class}").solutions.cut

  return if solutions_clipboard.items.empty?

  title = <<~HTML
    <h3 data-type="title">
      <span class="os-title-label">#{I18n.t(:"notes.#{note_class}")}</span>
    </h3>
  HTML

  append_to.append(child:
    Kitchen::Directions::SolutionAreaSnippet.v1(
      title: title, solutions_clipboard: solutions_clipboard
    )
  )
end