Module: Kitchen::Directions::BakeNoteExercise
- Defined in:
- lib/kitchen/directions/bake_notes/bake_note_exercise.rb
Class Method Summary collapse
Class Method Details
.v1(note:, exercise:, divider: ' ', suppress_solution: false) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/kitchen/directions/bake_notes/bake_note_exercise.rb', line 6 def self.v1(note:, exercise:, divider: ' ', suppress_solution: false) exercise.add_class('unnumbered') number = note.first('.os-number').text.gsub(/#/, '') # bake problem exercise.problem.wrap_children('div', class: 'os-problem-container') exercise.search('[data-type="commentary"]').each(&:trash) return unless exercise.solution # bake solution in place if suppress_solution exercise.add_class('os-hasSolution') exercise.solution.trash else BakeNumberedExercise.bake_solution_v1( exercise: exercise, number: number, divider: divider ) end end |
.v2(note:) ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/kitchen/directions/bake_notes/bake_note_exercise.rb', line 28 def self.v2(note:) note.exercises.each do |exercise| exercise.problem.wrap_children('div', class: 'os-problem-container') unless exercise.has_class?('unnumbered') exercise.problem.prepend(child: <<~HTML <span class="os-title-label">#{I18n.t(:"exercises.exercise")} </span> <span class="os-number">#{exercise.count_in(:note)}</span> HTML ) end next unless exercise.solution exercise.solution.wrap_children('div', class: 'os-solution-container') exercise.solution.prepend(child: <<~HTML <span class="os-title-label">#{I18n.t(:"exercises.solution")}</span> HTML ) end end |