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.
- #tsort_each_child(node, &block) ⇒ Object
- #tsort_each_node(&block) ⇒ Object
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
46 47 48 49 50 |
# File 'lib/usecasing/execution_order.rb', line 46 def cyclic? components = strongly_connected_components result = components.any?{ |component| component.size != 1 } [ result, components.select{|component| component.size != 1 } ] end |
#tsort_each_child(node, &block) ⇒ Object
42 43 44 |
# File 'lib/usecasing/execution_order.rb', line 42 def tsort_each_child(node, &block) node.dependencies.each &block end |
#tsort_each_node(&block) ⇒ Object
38 39 40 |
# File 'lib/usecasing/execution_order.rb', line 38 def tsort_each_node(&block) @nodes.each &block end |