Sha256: 7647ba6b42e825965a0db5633de4cd75617c184bc14ee21a67d594970b5270b9

Contents?: true

Size: 1.33 KB

Versions: 2

Compression:

Stored size: 1.33 KB

Contents

# frozen_string_literal: true

# Public: An object representing a Trivia Crack Question, including the list of
# available answers as well as the correct answer.
module TriviaCrack
  class Question
    # Public: The unique identifier of the question.
    attr_reader :id

    # Public: The type of the question (e.g. :normal, :crown, :duel).
    attr_reader :type

    # Public: The category of the question (e.g. :arts, :geography, etc).
    attr_reader :category

    # Public: The question text.
    attr_reader :text

    # Public: The list of possible answers to the question.
    attr_reader :answers

    # Public: The index of the correct answer (based on the :answers property).
    attr_reader :correct_answer

    # Public: The type of media used by the question (e.g. :normal, :image).
    attr_reader :media_type

    # Public: The URL for the image.
    attr_reader :image_url

    def initialize(id:, type: nil, category: nil, text: nil, answers: nil, # rubocop:disable Metrics/ParameterLists
                   correct_answer: nil, media_type: nil, image_url: nil)
      @id             = id
      @type           = type
      @category       = category
      @text           = text
      @answers        = answers
      @correct_answer = correct_answer
      @media_type     = media_type
      @image_url      = image_url
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
triviacrack-0.8.0 lib/triviacrack/question.rb
triviacrack-0.7.0 lib/triviacrack/question.rb