Class: DSort::Cyclic

Inherits:
TSort::Cyclic
  • Object
show all
Defined in:
lib/prick/dsort.rb

Overview

Thrown if a cyclic dependency is detected

DSort::Cyclic is inherited from TSort::Cyclic so that recue handling code written for TSort will still work. It provides a #cycles member that lists the cycles

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(dsort_object) ⇒ Cyclic

Returns a new instance of Cyclic.



13
14
15
16
17
18
19
20
# File 'lib/prick/dsort.rb', line 13

def initialize(dsort_object)
  @cycles = 
      dsort_object.each_strongly_connected_component \
        .select { |e| e.size > 1 } \
        .sort { |l,r| r <=> l }
  gram = cycles.size > 1 ? "ies" : "y"
  super("Cyclic depedendenc#{gram} detected")
end

Instance Attribute Details

#cyclesObject (readonly)

List of detected cycles sorted from shortest to longest cycle



11
12
13
# File 'lib/prick/dsort.rb', line 11

def cycles
  @cycles
end