Class: Smartdown::Engine::Transition
- Inherits:
-
Object
- Object
- Smartdown::Engine::Transition
- Defined in:
- lib/smartdown/engine/transition.rb
Instance Attribute Summary collapse
-
#answers ⇒ Object
readonly
Returns the value of attribute answers.
-
#node ⇒ Object
readonly
Returns the value of attribute node.
-
#state ⇒ Object
readonly
Returns the value of attribute state.
Instance Method Summary collapse
-
#initialize(state, node, answers, options = {}) ⇒ Transition
constructor
A new instance of Transition.
- #next_node ⇒ Object
- #next_state ⇒ Object
Constructor Details
#initialize(state, node, answers, options = {}) ⇒ Transition
Returns a new instance of Transition.
8 9 10 11 12 |
# File 'lib/smartdown/engine/transition.rb', line 8 def initialize(state, node, answers, = {}) @state = state @node = node @answers = answers end |
Instance Attribute Details
#answers ⇒ Object (readonly)
Returns the value of attribute answers.
6 7 8 |
# File 'lib/smartdown/engine/transition.rb', line 6 def answers @answers end |
#node ⇒ Object (readonly)
Returns the value of attribute node.
6 7 8 |
# File 'lib/smartdown/engine/transition.rb', line 6 def node @node end |
#state ⇒ Object (readonly)
Returns the value of attribute state.
6 7 8 |
# File 'lib/smartdown/engine/transition.rb', line 6 def state @state end |
Instance Method Details
#next_node ⇒ Object
14 15 16 17 18 |
# File 'lib/smartdown/engine/transition.rb', line 14 def next_node next_node_from_next_node_rules || || raise(Smartdown::Engine::IndeterminateNextNode, "No next node rules defined for '#{node.name}'", caller) end |
#next_state ⇒ Object
20 21 22 23 24 25 |
# File 'lib/smartdown/engine/transition.rb', line 20 def next_state state_with_responses .put(:path, state.get(:path) + [node.name]) .put(:accepted_responses, state.get(:accepted_responses) + answers.map(&:to_s)) .put(:current_node, next_node) end |