Module: Blood
- Defined in:
- lib/blood.rb,
lib/blood/version.rb
Defined Under Namespace
Constant Summary collapse
- VERSION =
"0.1.2"
Class Method Summary collapse
Class Method Details
.source(mods) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/blood.rb', line 9 def self.source(mods) hier = Hash.new{ |h, k| h[k] = Set.new } mods.each do |mod| # maybe [Class, [Module, Module], ...] ances = mod.ancestors.reduce([]) do |arr, a| next arr << a if Class === a arr << Modules.new unless Modules === arr[-1] arr[-1].add(a) arr end ances.each_with_index do |child, i| parent = ances[i + 1] hier[parent] << child end end Node.new(BasicObject, hier) end |