Class: GuidedPath::QuestionMultipleChoiceNode
- Defined in:
- lib/guided_path/question_multiple_choice_node.rb
Instance Attribute Summary collapse
-
#answers ⇒ Object
readonly
Returns the value of attribute answers.
-
#text ⇒ Object
readonly
Returns the value of attribute text.
Attributes inherited from Node
Instance Method Summary collapse
-
#initialize(args = {}) ⇒ QuestionMultipleChoiceNode
constructor
A new instance of QuestionMultipleChoiceNode.
- #to_hash ⇒ Object
Constructor Details
#initialize(args = {}) ⇒ QuestionMultipleChoiceNode
Returns a new instance of QuestionMultipleChoiceNode.
9 10 11 12 13 14 15 16 |
# File 'lib/guided_path/question_multiple_choice_node.rb', line 9 def initialize(args = {}) super args = args.symbolize_keys @answers = args[:answers] raise(ArgumentError, "Must specify answers in an Hash") unless args[:answers] && args[:answers].kind_of?(Hash) @text = args[:text] end |
Instance Attribute Details
#answers ⇒ Object (readonly)
Returns the value of attribute answers.
7 8 9 |
# File 'lib/guided_path/question_multiple_choice_node.rb', line 7 def answers @answers end |
#text ⇒ Object (readonly)
Returns the value of attribute text.
7 8 9 |
# File 'lib/guided_path/question_multiple_choice_node.rb', line 7 def text @text end |
Instance Method Details
#to_hash ⇒ Object
19 20 21 22 23 24 25 |
# File 'lib/guided_path/question_multiple_choice_node.rb', line 19 def to_hash output = super output[:type] = 'question_multiple_choice' output[:answers] = Hash[@answers.collect { |answer,node| [answer, node.label] }] output[:text] = @text return output end |