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

Instance Method Summary collapse

Instance Attribute Details

#start_stateObject

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

#statesObject

Returns the value of attribute states.



23
24
25
# File 'lib/aws/flow/simple_dfa.rb', line 23

def states
  @states
end

#symbolsObject

Returns the value of attribute symbols.



23
24
25
# File 'lib/aws/flow/simple_dfa.rb', line 23

def symbols
  @symbols
end

#transitionsObject

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_stateObject

Returns the start state The start state that was provided when this instance was created.

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_transitionsArray

Returns The list of all transitions that were added with #add_transition.

Returns:

  • (Array)

    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.

Parameters:

  • start_state

    The state with which to start the framework.



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_transitionsObject



67
68
69
# File 'lib/aws/flow/simple_dfa.rb', line 67

def uncovered_transitions
  @states.product(@symbols) - @transitions.keys
end