Module: AWS::Flow::Core::SimpleDFA
- Included in:
- BeginRescueEnsure
- Defined in:
- lib/aws/flow/simple_dfa.rb
Overview
Contains a Data Flow Analysis (DFA)-like framework, where transition functions can perform arbitrary computation before moving to the next state
Defined Under Namespace
Modules: InstanceMethods
Instance Attribute Summary collapse
-
#start_state ⇒ Object
Returns the value of attribute start_state.
-
#states ⇒ Object
Returns the value of attribute states.
-
#symbols ⇒ Object
Returns the value of attribute symbols.
-
#transitions ⇒ Object
Returns the value of attribute transitions.
Instance Method Summary collapse
- #add_transition(state, symbol, &block) ⇒ Object
- #define_general(state, &block) ⇒ Object
-
#get_start_state ⇒ Object
The start state The start state that was provided when this instance was created.
-
#get_transitions ⇒ Array
The list of all transitions that were added with #add_transition.
-
#init(start_state) ⇒ Object
Creates a new SimpleDFA instance.
- #uncovered_transitions ⇒ Object
Instance Attribute Details
#start_state ⇒ Object
Returns the value of attribute start_state.
23 24 25 |
# File 'lib/aws/flow/simple_dfa.rb', line 23 def start_state @start_state end |
#states ⇒ Object
Returns the value of attribute states.
23 24 25 |
# File 'lib/aws/flow/simple_dfa.rb', line 23 def states @states end |
#symbols ⇒ Object
Returns the value of attribute symbols.
23 24 25 |
# File 'lib/aws/flow/simple_dfa.rb', line 23 def symbols @symbols end |
#transitions ⇒ Object
Returns the value of attribute transitions.
23 24 25 |
# File 'lib/aws/flow/simple_dfa.rb', line 23 def transitions @transitions end |
Instance Method Details
#add_transition(state, symbol, &block) ⇒ Object
61 62 63 64 65 |
# File 'lib/aws/flow/simple_dfa.rb', line 61 def add_transition(state, symbol, &block) @symbols << symbol unless @symbols.include? symbol @states << state unless @states.include? state @transitions[[state, symbol]] = block end |
#define_general(state, &block) ⇒ Object
53 54 55 56 57 58 59 |
# File 'lib/aws/flow/simple_dfa.rb', line 53 def define_general(state, &block) @symbols.each do |symbol| if @transitions[[state, symbol]].nil? @transitions[[state, symbol]] = block end end end |
#get_start_state ⇒ Object
Returns the start state The start state that was provided when this instance was created.
42 43 44 |
# File 'lib/aws/flow/simple_dfa.rb', line 42 def get_start_state @start_state end |
#get_transitions ⇒ Array
Returns The list of all transitions that were added with #add_transition.
49 50 51 |
# File 'lib/aws/flow/simple_dfa.rb', line 49 def get_transitions @transitions end |
#init(start_state) ⇒ Object
Creates a new SimpleDFA instance.
30 31 32 33 34 35 36 37 |
# File 'lib/aws/flow/simple_dfa.rb', line 30 def init(start_state) include InstanceMethods @start_state = start_state @symbols = [] @states = [] @transitions = {} @states << start_state end |
#uncovered_transitions ⇒ Object
67 68 69 |
# File 'lib/aws/flow/simple_dfa.rb', line 67 def uncovered_transitions @states.product(@symbols) - @transitions.keys end |