class Kitchen::Directions::MoveSolutionsFromExerciseSection::V1

Public Instance Methods

bake(chapter:, append_to:, section_class:, title_number:) click to toggle source
# 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