Class: CatEngine::Question
- Inherits:
-
Struct
- Object
- Struct
- CatEngine::Question
- Extended by:
- ActiveModel::Naming
- Includes:
- ActiveModel::Conversion
- Defined in:
- lib/cat_engine/question.rb
Defined Under Namespace
Classes: XMLMapper
Instance Attribute Summary collapse
-
#context ⇒ Object
Returns the value of attribute context.
-
#id ⇒ Object
Returns the value of attribute id.
-
#promis_id ⇒ Object
Returns the value of attribute promis_id.
-
#response ⇒ Object
Returns the value of attribute response.
-
#response_before ⇒ Object
Returns the value of attribute response_before.
-
#responses ⇒ Object
Returns the value of attribute responses.
-
#responses_attributes ⇒ Object
Returns the value of attribute responses_attributes.
-
#selected_response_index ⇒ Object
Returns the value of attribute selected_response_index.
-
#title ⇒ Object
Returns the value of attribute title.
Instance Method Summary collapse
- #context_and_title ⇒ Object
-
#initialize(attributes = nil) ⇒ Question
constructor
A new instance of Question.
- #persisted? ⇒ Boolean
- #selected_response ⇒ Object
- #xml=(xml) ⇒ Object
Constructor Details
#initialize(attributes = nil) ⇒ Question
Returns a new instance of Question.
9 10 11 |
# File 'lib/cat_engine/question.rb', line 9 def initialize attributes = nil assign_attributes(attributes || {}) end |
Instance Attribute Details
#context ⇒ Object
Returns the value of attribute context
5 6 7 |
# File 'lib/cat_engine/question.rb', line 5 def context @context end |
#id ⇒ Object
Returns the value of attribute id
5 6 7 |
# File 'lib/cat_engine/question.rb', line 5 def id @id end |
#promis_id ⇒ Object
Returns the value of attribute promis_id
5 6 7 |
# File 'lib/cat_engine/question.rb', line 5 def promis_id @promis_id end |
#response ⇒ Object
Returns the value of attribute response.
23 24 25 |
# File 'lib/cat_engine/question.rb', line 23 def response @response end |
#response_before ⇒ Object
Returns the value of attribute response_before
5 6 7 |
# File 'lib/cat_engine/question.rb', line 5 def response_before @response_before end |
#responses ⇒ Object
Returns the value of attribute responses
5 6 7 |
# File 'lib/cat_engine/question.rb', line 5 def responses @responses end |
#responses_attributes ⇒ Object
Returns the value of attribute responses_attributes.
23 24 25 |
# File 'lib/cat_engine/question.rb', line 23 def responses_attributes @responses_attributes end |
#selected_response_index ⇒ Object
Returns the value of attribute selected_response_index.
23 24 25 |
# File 'lib/cat_engine/question.rb', line 23 def selected_response_index @selected_response_index end |
#title ⇒ Object
Returns the value of attribute title
5 6 7 |
# File 'lib/cat_engine/question.rb', line 5 def title @title end |
Instance Method Details
#context_and_title ⇒ Object
13 14 15 |
# File 'lib/cat_engine/question.rb', line 13 def context_and_title [context, title].select(&:present?).join(" ") end |
#persisted? ⇒ Boolean
21 |
# File 'lib/cat_engine/question.rb', line 21 def persisted?; false; end |
#selected_response ⇒ Object
25 26 27 28 29 30 31 |
# File 'lib/cat_engine/question.rb', line 25 def selected_response if selected_response_index responses_attributes[selected_response_index] else { id: "00000000-0000-0000-0000-000000000000", title: response || "Skipped" } end end |