Sha256: ce7cb7c5890892687a3849edc38f92b8b585c573e2a455fd954efa4a6e327801

Contents?: true

Size: 1.16 KB

Versions: 1

Compression:

Stored size: 1.16 KB

Contents

# frozen_string_literal: true

module Kitchen
  # An element for an example
  #
  class ExerciseElement < ElementBase

    # Creates a new +ExerciseElement+
    #
    # @param node [Nokogiri::XML::Node] the node this element wraps
    # @param document [Document] this element's document
    #
    def initialize(node:, document: nil)
      super(node: node,
            document: document,
            enumerator_class: ExerciseElementEnumerator)
    end

    # Returns the short type
    # @return [Symbol]
    #
    def self.short_type
      :exercise
    end

    # Returns the enumerator for problem.
    #
    # @return ElementEnumerator
    #
    def problem
      first("div[data-type='problem']")
    end

    # Returns the enumerator for solution.
    #
    # @return ElementEnumerator
    #
    def solution
      first("div[data-type='solution']")
    end

    # Returns the enumerator for solutions
    #
    # @return [ElementEnumerator]
    #
    def solutions
      search("div[data-type='solution']")
    end

    # Returns whether the exercise has been baked
    #
    # @return [Boolean]
    #
    def baked?
      search('div.os-problem-container').any?
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
openstax_kitchen-11.2.0 lib/kitchen/exercise_element.rb