Class: UseCase::CyclicFinder
- Inherits:
-
Object
- Object
- UseCase::CyclicFinder
- Includes:
- TSort
- Defined in:
- lib/usecasing/execution_order.rb
Class Method Summary collapse
Instance Method Summary collapse
- #cyclic? ⇒ Boolean
-
#initialize(start_point) ⇒ CyclicFinder
constructor
A new instance of CyclicFinder.
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
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
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 |