class Answer

Attributes

answer_text[RW]
builder[R]
correct[R]
explanation[RW]
question[R]

Public Class Methods

new(answer_text, correct, explanation=nil) click to toggle source
# File lib/ruql/answer.rb, line 11
def initialize(answer_text, correct, explanation=nil)
  @answer_text = answer_text
  @correct = !!correct # ensure boolean
  @explanation = explanation
end

Public Instance Methods

<=>(other) click to toggle source
# File lib/ruql/answer.rb, line 8
def <=>(other) ; self.answer_text <=> other.answer_text ; end
as_json() click to toggle source
# File lib/ruql/answer.rb, line 17
def as_json
  Hash(:text => @answer_text, :correct => @correct,:explanation => @explanation).compact
end
correct?() click to toggle source
# File lib/ruql/answer.rb, line 9
def correct? ; !!correct ; end
has_explanation?() click to toggle source
# File lib/ruql/answer.rb, line 10
def has_explanation? ; !!explanation ; end