Class: TriviaCrack::Question

Inherits:
Object
  • Object
show all
Defined in:
lib/triviacrack/question.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id:, type: nil, category: nil, text: nil, answers: nil, correct_answer: nil, media_type: nil, image_url: nil) ⇒ Question

rubocop:disable Metrics/ParameterLists



31
32
33
34
35
36
37
38
39
40
41
# File 'lib/triviacrack/question.rb', line 31

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

Instance Attribute Details

#answersObject (readonly)

Public: The list of possible answers to the question.



20
21
22
# File 'lib/triviacrack/question.rb', line 20

def answers
  @answers
end

#categoryObject (readonly)

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



14
15
16
# File 'lib/triviacrack/question.rb', line 14

def category
  @category
end

#correct_answerObject (readonly)

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



23
24
25
# File 'lib/triviacrack/question.rb', line 23

def correct_answer
  @correct_answer
end

#idObject (readonly)

Public: The unique identifier of the question.



8
9
10
# File 'lib/triviacrack/question.rb', line 8

def id
  @id
end

#image_urlObject (readonly)

Public: The URL for the image.



29
30
31
# File 'lib/triviacrack/question.rb', line 29

def image_url
  @image_url
end

#media_typeObject (readonly)

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



26
27
28
# File 'lib/triviacrack/question.rb', line 26

def media_type
  @media_type
end

#textObject (readonly)

Public: The question text.



17
18
19
# File 'lib/triviacrack/question.rb', line 17

def text
  @text
end

#typeObject (readonly)

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



11
12
13
# File 'lib/triviacrack/question.rb', line 11

def type
  @type
end