Class: DSort::Cyclic
- Inherits:
-
TSort::Cyclic
- Object
- TSort::Cyclic
- DSort::Cyclic
- 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
-
#cycles ⇒ Object
readonly
List of detected cycles sorted from shortest to longest cycle.
Instance Method Summary collapse
-
#initialize(dsort_object) ⇒ Cyclic
constructor
A new instance of Cyclic.
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
#cycles ⇒ Object (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 |