Sha256: 4a7ea8e12bfb54006466dad78379540af5ce507ea3959fa23a0e2e4e40d9784c

Contents?: true

Size: 788 Bytes

Versions: 7

Compression:

Stored size: 788 Bytes

Contents

# frozen_string_literal: true

module Kitchen::Directions::MoveSolutionsToAnswerKey
  module Strategies
    class Default
      def bake(chapter:, append_to:)
        bake_section(chapter: chapter, append_to: append_to)
      end

      protected

      def bake_section(chapter:, append_to:)
        @selectors.each do |selector|
          chapter.search("#{selector} div[data-type='solution']").each do |solution|
            append_to.add_child(solution.cut.to_s)
          end
        end
      end

      # This method helps to obtain more strategy-specific params through
      # "strategy_options: {blah1: 1, blah2: 2}"
      def initialize(strategy_options)
        @selectors = strategy_options[:selectors] || (raise 'missing selectors for strategy')
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
openstax_kitchen-10.0.0 lib/kitchen/directions/move_solutions_to_answer_key/strategies/default.rb
openstax_kitchen-9.2.0 lib/kitchen/directions/move_solutions_to_answer_key/strategies/default.rb
openstax_kitchen-9.1.0 lib/kitchen/directions/move_solutions_to_answer_key/strategies/default.rb
openstax_kitchen-9.0.0 lib/kitchen/directions/move_solutions_to_answer_key/strategies/default.rb
openstax_kitchen-8.0.1 lib/kitchen/directions/move_solutions_to_answer_key/strategies/default.rb
openstax_kitchen-8.0.0 lib/kitchen/directions/move_solutions_to_answer_key/strategies/default.rb
openstax_kitchen-7.0.0 lib/kitchen/directions/move_solutions_to_answer_key/strategies/default.rb