Class: Kitchen::Directions::MoveSolutionsFromExerciseSection::V1

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

Instance Method Summary collapse

Instance Method Details

#bake(chapter:, append_to:, section_class:, title_number:) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/kitchen/directions/move_solutions_to_answer_key/move_solutions_from_exercise_section.rb', line 10

def bake(chapter:, append_to:, section_class:, title_number:)
  solutions_clipboard = chapter.search("section.#{section_class}").solutions.cut

  return if solutions_clipboard.items.empty?

  title_text = \
    if title_number
      I18n.t(:"eoc.#{section_class}", number: title_number)
    else
      I18n.t(:"eoc.#{section_class}")
    end
  title = <<~HTML
    <h3 data-type="title">
      <span class="os-title-label">#{title_text}</span>
    </h3>
  HTML

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