Class: CatEngine::Bank
- Inherits:
-
Struct
- Object
- Struct
- CatEngine::Bank
- Defined in:
- lib/cat_engine/bank.rb
Instance Attribute Summary collapse
-
#full_history ⇒ Object
Returns the value of attribute full_history.
-
#history ⇒ Object
Returns the value of attribute history.
-
#id ⇒ Object
(also: #to_param)
Returns the value of attribute id.
Instance Method Summary collapse
- #current_question ⇒ Object
- #finished? ⇒ Boolean
- #name ⇒ Object
- #paired? ⇒ Boolean
- #standard_error ⇒ Object
- #theta ⇒ Object
- #to_h ⇒ Object
- #valid_answer?(response_id) ⇒ Boolean
Instance Attribute Details
#full_history ⇒ Object
Returns the value of attribute full_history
5 6 7 |
# File 'lib/cat_engine/bank.rb', line 5 def full_history @full_history end |
#history ⇒ Object
Returns the value of attribute history
5 6 7 |
# File 'lib/cat_engine/bank.rb', line 5 def history @history end |
#id ⇒ Object Also known as: to_param
Returns the value of attribute id
5 6 7 |
# File 'lib/cat_engine/bank.rb', line 5 def id @id end |
Instance Method Details
#current_question ⇒ Object
14 15 16 |
# File 'lib/cat_engine/bank.rb', line 14 def current_question Question.new(xml: xml) unless finished? end |
#finished? ⇒ Boolean
22 23 24 |
# File 'lib/cat_engine/bank.rb', line 22 def finished? xml.root.name == "Results" end |
#name ⇒ Object
10 11 12 |
# File 'lib/cat_engine/bank.rb', line 10 def name xml.root["Name"] end |
#paired? ⇒ Boolean
6 7 8 |
# File 'lib/cat_engine/bank.rb', line 6 def paired? id.include? "Illness Impact" end |
#standard_error ⇒ Object
31 32 33 34 |
# 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 ⇒ Object
26 27 28 29 |
# 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 ⇒ Object
36 37 38 39 40 41 42 |
# File 'lib/cat_engine/bank.rb', line 36 def to_h { finished: finished?, theta: theta, standard_error: standard_error, } end |
#valid_answer?(response_id) ⇒ Boolean
18 19 20 |
# File 'lib/cat_engine/bank.rb', line 18 def valid_answer?(response_id) engine.valid_history?(id, [history, response_id].join(" ")) end |