Class: Maruto::ModuleDefinition::ModuleSorter

Inherits:
Object
  • Object
show all
Includes:
TSort
Defined in:
lib/maruto/module_definition.rb

Instance Method Summary collapse

Constructor Details

#initialize(h) ⇒ ModuleSorter

Returns a new instance of ModuleSorter.



63
64
65
# File 'lib/maruto/module_definition.rb', line 63

def initialize(h)
	@h = h
end

Instance Method Details

#sortedObject



72
73
74
# File 'lib/maruto/module_definition.rb', line 72

def sorted
	tsort.map { |mod_name| @h[mod_name] }
end

#tsort_each_child(mod_name, &block) ⇒ Object



69
70
71
# File 'lib/maruto/module_definition.rb', line 69

def tsort_each_child(mod_name, &block)
	@h[mod_name][:dependencies].each(&block) if @h[mod_name].include? :dependencies
end

#tsort_each_node(&block) ⇒ Object



66
67
68
# File 'lib/maruto/module_definition.rb', line 66

def tsort_each_node(&block)
	@h.each_key(&block)
end