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

Returns a new instance of Question.



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

def initialize(id:, type: nil, category: nil, text: nil, answers: nil,
               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.



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

def answers
  @answers
end

#categoryObject (readonly)

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



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

def category
  @category
end

#correct_answerObject (readonly)

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



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

def correct_answer
  @correct_answer
end

#idObject (readonly)

Public: The unique identifier of the question.



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

def id
  @id
end

#image_urlObject (readonly)

Public: The URL for the image.



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

def image_url
  @image_url
end

#media_typeObject (readonly)

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



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

def media_type
  @media_type
end

#textObject (readonly)

Public: The question text.



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

def text
  @text
end

#typeObject (readonly)

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



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

def type
  @type
end