class CatEngine::Bank

Public Instance Methods

current_question() click to toggle source
# File lib/cat_engine/bank.rb, line 14
def current_question
  Question.new(xml: xml) unless finished?
end
finished?() click to toggle source
# File lib/cat_engine/bank.rb, line 22
def finished?
  xml.root.name == "Results"
end
name() click to toggle source
# File lib/cat_engine/bank.rb, line 10
def name
  xml.root["Name"]
end
paired?() click to toggle source
# File lib/cat_engine/bank.rb, line 6
def paired?
  id.include? "Illness Impact"
end
standard_error() click to toggle source
# File lib/cat_engine/bank.rb, line 31
def standard_error
  return unless xml.root.key?("StdError")
  (10 * xml.root["StdError"].to_f).round
end
theta() click to toggle source
# File lib/cat_engine/bank.rb, line 26
def theta
  return unless xml.root.key?("Theta")
  (10 * xml.root["Theta"].to_f + 50).round
end
to_h() click to toggle source
# File lib/cat_engine/bank.rb, line 36
def to_h
  {
    finished: finished?,
    theta: theta,
    standard_error: standard_error,
  }
end
valid_answer?(response_id) click to toggle source
# File lib/cat_engine/bank.rb, line 18
def valid_answer?(response_id)
  engine.valid_history?(id, [history, response_id].join(" "))
end

Private Instance Methods

engine() click to toggle source
# File lib/cat_engine/bank.rb, line 52
def engine
  id.include?(".flat") ? FlatEngine.new(full_history) : Engine.new
end
xml() click to toggle source
# File lib/cat_engine/bank.rb, line 48
def xml
  engine.process(id, history)
end