Class: UseCase::CyclicFinder

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

Instance Method Summary collapse

Constructor Details

#initialize(start_point) ⇒ CyclicFinder

Returns a new instance of CyclicFinder.



9
10
11
12
# File 'lib/usecasing/cyclic_finder.rb', line 9

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

Instance Method Details

#cyclic?Boolean

Returns:

  • (Boolean)


22
23
24
25
26
# File 'lib/usecasing/cyclic_finder.rb', line 22

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



18
19
20
# File 'lib/usecasing/cyclic_finder.rb', line 18

def tsort_each_child(node, &block)
  node.dependencies.each &block
end

#tsort_each_node(&block) ⇒ Object



14
15
16
# File 'lib/usecasing/cyclic_finder.rb', line 14

def tsort_each_node(&block)
  @nodes.each &block
end