Module: EnumMachineContrib::HasDecisionTree

Defined in:
lib/enum_machine_contrib/has_decision_tree.rb

Instance Method Summary collapse

Instance Method Details

#decision_treeObject



6
7
8
9
10
11
12
# File 'lib/enum_machine_contrib/has_decision_tree.rb', line 6

def decision_tree
  start_values = @transitions.keys - @transitions.values.flatten.uniq
  raise EnumMachine::InvalidTransitionGraph, 'There is no start value' if start_values.empty?
  raise EnumMachine::InvalidTransitionGraph, 'Multiple graphs detected' if start_values.size > 1

  DecisionGraph.new(@transitions).decision_tree
end