class Kitchen::Directions::MoveSolutionsToAnswerKey::Strategies::Default

Public Class Methods

new(strategy_options) click to toggle source

This method helps to obtain more strategy-specific params through “strategy_options: {blah1: 1, blah2: 2}”

# File lib/kitchen/directions/move_solutions_to_answer_key/strategies/default.rb, line 22
def initialize(strategy_options)
  @selectors = strategy_options[:selectors] || (raise 'missing selectors for strategy')
end

Public Instance Methods

bake(chapter:, append_to:) click to toggle source
# File lib/kitchen/directions/move_solutions_to_answer_key/strategies/default.rb, line 6
def bake(chapter:, append_to:)
  bake_section(chapter: chapter, append_to: append_to)
end

Protected Instance Methods

bake_section(chapter:, append_to:) click to toggle source
# File lib/kitchen/directions/move_solutions_to_answer_key/strategies/default.rb, line 12
def bake_section(chapter:, append_to:)
  @selectors.each do |selector|
    chapter.search("#{selector} div[data-type='solution']").each do |solution|
      append_to.append(child: solution.cut.to_s)
    end
  end
end