Class: GuidedPath::QuestionTextBoxNode

Inherits:
Node
  • Object
show all
Defined in:
lib/guided_path/question_textbox_node.rb

Instance Attribute Summary collapse

Attributes inherited from Node

#label, #next_node

Instance Method Summary collapse

Constructor Details

#initialize(args = {}) ⇒ QuestionTextBoxNode

Returns a new instance of QuestionTextBoxNode.

Raises:

  • (ArgumentError)


9
10
11
12
13
14
15
16
17
# File 'lib/guided_path/question_textbox_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

#answersObject (readonly)

Returns the value of attribute answers.



7
8
9
# File 'lib/guided_path/question_textbox_node.rb', line 7

def answers
  @answers
end

#blankObject (readonly)

Returns the value of attribute blank.



7
8
9
# File 'lib/guided_path/question_textbox_node.rb', line 7

def blank
  @blank
end

#otherwiseObject (readonly)

Returns the value of attribute otherwise.



7
8
9
# File 'lib/guided_path/question_textbox_node.rb', line 7

def otherwise
  @otherwise
end

#textObject (readonly)

Returns the value of attribute text.



7
8
9
# File 'lib/guided_path/question_textbox_node.rb', line 7

def text
  @text
end

Instance Method Details

#to_hashObject



20
21
22
23
24
25
26
# File 'lib/guided_path/question_textbox_node.rb', line 20

def to_hash
  output = super
  output[:type] = 'question_text_box'
  output[:answers] = Hash[@answers.collect { |answer,node| [answer, node.label] }]
  output[:text] = @text
  return output
end