Class: SynFlowFactory
Overview
The SynFlowFactory
define the common part for a set of flows.
A SynFlow is like an automaton (finite state machine):
* states
* transitions
* an alphabet
* an initial state
* a set of final states
With this automaton (diagram, graph…) you can easily describe important steps of your program control flow.
Your automaton describe a model of execution and constraint every execution to it.
When a thread want to change the state of its flow it proceed like that:
flow << :a_symbol_of_the_alphabet
If a transition between the current state and a state destination is labeled by symbol, then the state is updated to destination. Otherwise the thread is constraint to wait the modification of the current state.
See examples below to know how to use these class.
Defined Under Namespace
Classes: Transition, TransitionSet
Instance Attribute Summary collapse
-
#initial ⇒ Object
Returns the value of attribute initial.
-
#transitions ⇒ Object
Returns the value of attribute transitions.
Instance Method Summary collapse
- #<<(transition) ⇒ Object
- #delta(src, label) ⇒ Object
- #include?(*transition) ⇒ Boolean
- #initial?(state) ⇒ Boolean
-
#initialize ⇒ SynFlowFactory
constructor
A new instance of SynFlowFactory.
- #new_flow ⇒ Object
Constructor Details
#initialize ⇒ SynFlowFactory
Returns a new instance of SynFlowFactory.
132 133 134 135 |
# File 'lib/syn_flow.rb', line 132 def initialize @transitions = TransitionSet.new @initial = nil end |
Instance Attribute Details
#initial ⇒ Object
Returns the value of attribute initial.
129 130 131 |
# File 'lib/syn_flow.rb', line 129 def initial @initial end |
#transitions ⇒ Object
Returns the value of attribute transitions.
129 130 131 |
# File 'lib/syn_flow.rb', line 129 def transitions @transitions end |
Instance Method Details
#<<(transition) ⇒ Object
138 139 140 141 |
# File 'lib/syn_flow.rb', line 138 def << ( transition ) @transitions << transition self end |
#delta(src, label) ⇒ Object
149 150 151 |
# File 'lib/syn_flow.rb', line 149 def delta ( src, label ) @transitions.delta(src, label) end |
#include?(*transition) ⇒ Boolean
144 145 146 |
# File 'lib/syn_flow.rb', line 144 def include? ( *transition ) @transitions.include?(*transition) end |
#initial?(state) ⇒ Boolean
159 160 161 |
# File 'lib/syn_flow.rb', line 159 def initial? ( state ) state == @initial end |