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.


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

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


20
21
22
23
# File 'lib/watir/generator/base/idl_sorter.rb', line 20

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

#sortObject


25
26
27
# File 'lib/watir/generator/base/idl_sorter.rb', line 25

def sort
  tsort.reverse
end

#tsort_each_child(node, &blk) ⇒ Object


33
34
35
# File 'lib/watir/generator/base/idl_sorter.rb', line 33

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

#tsort_each_node(&blk) ⇒ Object


29
30
31
# File 'lib/watir/generator/base/idl_sorter.rb', line 29

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