Class: Watir::Generator::Base::IDLSorter

Inherits:
Object
  • Object
show all
Includes:
TSort
Defined in:
lib/watir/generator/base/idl_sorter.rb

Instance Method Summary collapse

Constructor Details

#initialize(interfaces) ⇒ IDLSorter

Returns a new instance of IDLSorter.



11
12
13
14
15
16
17
18
19
20
# File 'lib/watir/generator/base/idl_sorter.rb', line 11

def initialize(interfaces)
  @interfaces = {}

  interfaces.each do |interface|
    @interfaces[interface.name] ||= []
    interface.inherits.each do |inherit|
      (@interfaces[inherit.name] ||= []) << interface.name
    end
  end
end

Instance Method Details



22
23
24
25
# File 'lib/watir/generator/base/idl_sorter.rb', line 22

def print
  @visited = []
  sort.each { |node| print_node(node) }
end

#sortObject



27
28
29
# File 'lib/watir/generator/base/idl_sorter.rb', line 27

def sort
  tsort.reverse
end

#tsort_each_child(node, &blk) ⇒ Object



35
36
37
# File 'lib/watir/generator/base/idl_sorter.rb', line 35

def tsort_each_child(node, &blk)
  @interfaces[node].each(&blk)
end

#tsort_each_node(&blk) ⇒ Object



31
32
33
# File 'lib/watir/generator/base/idl_sorter.rb', line 31

def tsort_each_node(&blk)
  @interfaces.each_key(&blk)
end