class Answer
Attributes
answer_text[RW]
builder[R]
correct[RW]
explanation[RW]
question[R]
Public Class Methods
from_JSON(hash)
click to toggle source
# File lib/ruql/answer.rb, line 21 def self.from_JSON(hash) answer = Answer.new hash.each do |key, value| answer.send((key + '=').to_sym, value) end answer end
new(answer_text = '', correct = false, explanation=nil)
click to toggle source
# File lib/ruql/answer.rb, line 11 def initialize(answer_text = '', correct = false, 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
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
to_JSON()
click to toggle source
# File lib/ruql/answer.rb, line 17 def to_JSON Hash[instance_variables.collect { |var| [var.to_s.delete('@'), instance_variable_get(var)] }] end