Class: UseCase::CyclicFinder

Inherits:
Object
  • Object
show all
Includes:
TSort
Defined in:
lib/usecasing/execution_order.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(start_point) ⇒ CyclicFinder

Returns a new instance of CyclicFinder.



33
34
35
36
# File 'lib/usecasing/execution_order.rb', line 33

def initialize(start_point)
  @start_point = start_point
  @nodes       = discover_nodes
end

Class Method Details

.cyclic?(start_point) ⇒ Boolean

Returns:

  • (Boolean)


29
30
31
# File 'lib/usecasing/execution_order.rb', line 29

def self.cyclic?(start_point)
  new(start_point).cyclic?
end

Instance Method Details

#cyclic?Boolean

Returns:

  • (Boolean)


39
40
41
42
43
# File 'lib/usecasing/execution_order.rb', line 39

def cyclic?
  components = strongly_connected_components
  result = components.any?{ |component| component.size != 1 }
  [ result, components.select{|component| component.size != 1 } ]
end