Class: SynFlowFactory

Inherits:
Object show all
Defined in:
lib/syn_flow.rb

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

Instance Method Summary collapse

Constructor Details

#initializeSynFlowFactory

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

#initialObject

Returns the value of attribute initial.



129
130
131
# File 'lib/syn_flow.rb', line 129

def initial
  @initial
end

#transitionsObject

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

Returns:

  • (Boolean)


144
145
146
# File 'lib/syn_flow.rb', line 144

def include? ( *transition )
  @transitions.include?(*transition)
end

#initial?(state) ⇒ Boolean

Returns:

  • (Boolean)


159
160
161
# File 'lib/syn_flow.rb', line 159

def initial? ( state )
  state == @initial
end

#new_flowObject



154
155
156
# File 'lib/syn_flow.rb', line 154

def new_flow
  SynFlow.new(self, @initial)
end