class Answer
Attributes
answer[RW]
kind[RW]
order[RW]
Public Class Methods
new(order, kind, answer)
click to toggle source
order: the position of the answer in the question kind: either :right or :wrong answer: the text of the answer (for instance “1492”)
# File lib/quiz/answer.rb, line 7 def initialize(order, kind, answer) @kind, @order, @answer = kind, order, answer end
Public Instance Methods
<=>(other)
click to toggle source
Answer
objects must be sorted according to their position inside the question
# File lib/quiz/answer.rb, line 22 def <=>(other) self.order <=> other.order end
is_right?()
click to toggle source
decides if this is a right answer
# File lib/quiz/answer.rb, line 16 def is_right? @kind == Quiz::RIGHT end
to_s()
click to toggle source
# File lib/quiz/answer.rb, line 11 def to_s "#{@order}. #{answer}" end