Sha256: d00c5cb05d98fe3d4c3e40837370cce8b7bfeae89ea4b1d30f630e4cf2c3d5e7

Contents?: true

Size: 1012 Bytes

Versions: 13

Compression:

Stored size: 1012 Bytes

Contents

# frozen_string_literal: true

module Kitchen::Directions::MoveSolutionsFromExerciseSection
  def self.v1(chapter:, append_to:, section_class:, title_number: nil)
    V1.new.bake(chapter: chapter, append_to: append_to, section_class: section_class,
                title_number: title_number)
  end

  class V1
    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
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
openstax_kitchen-19.0.0 lib/kitchen/directions/move_solutions_to_answer_key/move_solutions_from_exercise_section.rb
openstax_kitchen-18.0.0 lib/kitchen/directions/move_solutions_to_answer_key/move_solutions_from_exercise_section.rb
openstax_kitchen-17.1.0 lib/kitchen/directions/move_solutions_to_answer_key/move_solutions_from_exercise_section.rb
openstax_kitchen-17.0.0 lib/kitchen/directions/move_solutions_to_answer_key/move_solutions_from_exercise_section.rb
openstax_kitchen-16.0.0 lib/kitchen/directions/move_solutions_to_answer_key/move_solutions_from_exercise_section.rb
openstax_kitchen-15.0.0 lib/kitchen/directions/move_solutions_to_answer_key/move_solutions_from_exercise_section.rb
openstax_kitchen-14.0.0 lib/kitchen/directions/move_solutions_to_answer_key/move_solutions_from_exercise_section.rb
openstax_kitchen-13.0.0 lib/kitchen/directions/move_solutions_to_answer_key/move_solutions_from_exercise_section.rb
openstax_kitchen-12.2.0 lib/kitchen/directions/move_solutions_to_answer_key/move_solutions_from_exercise_section.rb
openstax_kitchen-12.1.0 lib/kitchen/directions/move_solutions_to_answer_key/move_solutions_from_exercise_section.rb
openstax_kitchen-12.0.0 lib/kitchen/directions/move_solutions_to_answer_key/move_solutions_from_exercise_section.rb
openstax_kitchen-11.2.0 lib/kitchen/directions/move_solutions_to_answer_key/move_solutions_from_exercise_section.rb
openstax_kitchen-11.1.0 lib/kitchen/directions/move_solutions_to_answer_key/move_solutions_from_exercise_section.rb