Class: Ofe::TSortedFiles

Inherits:
Object
  • Object
show all
Includes:
TSort
Defined in:
lib/ofe/t_sorted_files.rb

Overview


CLASS->T-SORTED-FILES ————————


Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(files, topology = {}) ⇒ TSortedFiles


INITIALIZE ———————————




17
18
19
20
21
22
23
24
25
26
27
# File 'lib/ofe/t_sorted_files.rb', line 17

def initialize(files, topology={})
  @topology = topology

  # The topology will most likely only have a few keys/files
  # set so we need to append the rest (as empty arrays).
  #
  # This way we can sort all of them.
  files.each do |file|
    @topology[file] = [] unless @topology[file]
  end
end

Instance Attribute Details

#filesObject


ATTRIBUTES ———————————




12
13
14
# File 'lib/ofe/t_sorted_files.rb', line 12

def files
  @files
end

#topologyObject


ATTRIBUTES ———————————




12
13
14
# File 'lib/ofe/t_sorted_files.rb', line 12

def topology
  @topology
end

Instance Method Details

#sortedObject



44
45
46
# File 'lib/ofe/t_sorted_files.rb', line 44

def sorted
  tsort
end

#tsort_each(&block) ⇒ Object


TSORT ————————————–




32
33
34
# File 'lib/ofe/t_sorted_files.rb', line 32

def tsort_each(&block)
  @topology.each(&block)
end

#tsort_each_child(node, &block) ⇒ Object



40
41
42
# File 'lib/ofe/t_sorted_files.rb', line 40

def tsort_each_child(node, &block)
  @topology[node].each(&block)
end

#tsort_each_node(&block) ⇒ Object



36
37
38
# File 'lib/ofe/t_sorted_files.rb', line 36

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