Class: Kitchen::Directions::MoveSolutionsFromAutotitledNote::V1

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

Instance Method Summary collapse

Instance Method Details

#bake(page:, append_to:, note_class:, title:) ⇒ Object



5
6
7
8
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_autotitled_note/v1.rb', line 5

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

  return if solutions_clipboard.items.empty?

  if title
    area_title = <<~HTML
      <h3 data-type="title">
        <span class="os-title-label">#{title}</span>
      </h3>
    HTML

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