Class: GuidedPath::Node
- Inherits:
-
Object
- Object
- GuidedPath::Node
- Defined in:
- lib/guided_path/node.rb
Direct Known Subclasses
GotoNode, LeadInNode, MultimediaNode, QuestionMultipleChoiceNode, QuestionTextBoxNode, TextNode
Instance Attribute Summary collapse
-
#label ⇒ Object
Returns the value of attribute label.
-
#next_node ⇒ Object
Returns the value of attribute next_node.
Instance Method Summary collapse
-
#initialize(args = {}) ⇒ Node
constructor
A new instance of Node.
- #to_hash ⇒ Object
Constructor Details
#initialize(args = {}) ⇒ Node
Returns a new instance of Node.
8 9 10 11 12 13 14 15 16 17 |
# File 'lib/guided_path/node.rb', line 8 def initialize(args = {}) raise(ArgumentError, "Options must be a hash") unless args.kind_of?(Hash) args = args.symbolize_keys @label = args[:label] @next_node = (args[:next_node] || args[:goto]) @next_node = @next_node.to_s.strip if @next_node end |
Instance Attribute Details
#label ⇒ Object
Returns the value of attribute label.
5 6 7 |
# File 'lib/guided_path/node.rb', line 5 def label @label end |
#next_node ⇒ Object
Returns the value of attribute next_node.
6 7 8 |
# File 'lib/guided_path/node.rb', line 6 def next_node @next_node end |
Instance Method Details
#to_hash ⇒ Object
23 24 25 26 27 28 29 30 |
# File 'lib/guided_path/node.rb', line 23 def to_hash output = {} if @next_node output[:next_node] = @next_node.respond_to?(:label) ? @next_node.label : @next_node.to_s end output end |