Sha256: 7d7855fc6fea220cbabe6d3ec2c01e0c2ad755ae5f38494a64cc715190484ab4

Contents?: true

Size: 550 Bytes

Versions: 17

Compression:

Stored size: 550 Bytes

Contents

module Screengem
  #
  # Common error to signal a question that was answered incorrectly.
  #
  class IncorrectAnswer < RuntimeError
    def initialize(question)
      super(extract_question_text(question))
    end

    private

    #
    # Transforms question class name into a text message.
    #
    # Example:
    #
    #   Questions::SignatureCapturedQuestion is transformed to 'Signature captured?'.
    #
    def extract_question_text(question)
      question.class.name.demodulize.underscore.humanize.gsub(" question", "?")
    end
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
screengem-0.10.1 lib/screengem/incorrect_answer.rb
screengem-0.10.0 lib/screengem/incorrect_answer.rb
screengem-0.9.1 lib/screengem/incorrect_answer.rb
screengem-0.9.0 lib/screengem/incorrect_answer.rb
screengem-0.8.1 lib/screengem/incorrect_answer.rb
screengem-0.8.0 lib/screengem/incorrect_answer.rb
screengem-0.7.3 lib/screengem/incorrect_answer.rb
screengem-0.7.2 lib/screengem/incorrect_answer.rb
screengem-0.7.1 lib/screengem/incorrect_answer.rb
screengem-0.6.0 lib/screengem/incorrect_answer.rb
screengem-0.5.0 lib/screengem/incorrect_answer.rb
screengem-0.4.0 lib/screengem/incorrect_answer.rb
screengem-0.3.0 lib/screengem/incorrect_answer.rb
screengem-0.2.0 lib/screengem/incorrect_answer.rb
screengem-0.1.2 lib/screengem/incorrect_answer.rb
screengem-0.1.1 lib/screengem/incorrect_answer.rb
screengem-0.1.0 lib/screengem/incorrect_answer.rb