Class: Smartdown::Engine::Transition
- Inherits:
-
Object
- Object
- Smartdown::Engine::Transition
- Defined in:
- lib/smartdown/engine/transition.rb
Instance Attribute Summary collapse
-
#input ⇒ Object
readonly
Returns the value of attribute input.
-
#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, input, options = {}) ⇒ Transition
constructor
A new instance of Transition.
- #next_node ⇒ Object
- #next_state ⇒ Object
Constructor Details
#initialize(state, node, input, options = {}) ⇒ Transition
Returns a new instance of Transition.
9 10 11 12 13 14 |
# File 'lib/smartdown/engine/transition.rb', line 9 def initialize(state, node, input, = {}) @state = state @node = node @input = input @predicate_evaluator = [:predicate_evaluator] || PredicateEvaluator.new end |
Instance Attribute Details
#input ⇒ Object (readonly)
Returns the value of attribute input.
7 8 9 |
# File 'lib/smartdown/engine/transition.rb', line 7 def input @input end |
#node ⇒ Object (readonly)
Returns the value of attribute node.
7 8 9 |
# File 'lib/smartdown/engine/transition.rb', line 7 def node @node end |
#state ⇒ Object (readonly)
Returns the value of attribute state.
7 8 9 |
# File 'lib/smartdown/engine/transition.rb', line 7 def state @state end |
Instance Method Details
#next_node ⇒ Object
16 17 18 19 20 |
# File 'lib/smartdown/engine/transition.rb', line 16 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
22 23 24 25 26 27 28 |
# File 'lib/smartdown/engine/transition.rb', line 22 def next_state state_with_input .put(:path, state.get(:path) + [node.name]) .put(:responses, state.get(:responses) + [input]) .put(input_variable_name, input) .put(:current_node, next_node) end |