Class: Watir::Generator::Base::IDLSorter
- Inherits:
-
Object
- Object
- Watir::Generator::Base::IDLSorter
- Includes:
- TSort
- Defined in:
- lib/watir-webdriver/generator/base/idl_sorter.rb
Instance Method Summary collapse
-
#initialize(interfaces) ⇒ IDLSorter
constructor
A new instance of IDLSorter.
- #print ⇒ Object
- #sort ⇒ Object
- #tsort_each_child(node, &blk) ⇒ Object
- #tsort_each_node(&blk) ⇒ Object
Constructor Details
#initialize(interfaces) ⇒ IDLSorter
Returns a new instance of IDLSorter.
8 9 10 11 12 13 14 15 16 17 |
# File 'lib/watir-webdriver/generator/base/idl_sorter.rb', line 8 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
#print ⇒ Object
19 20 21 22 |
# File 'lib/watir-webdriver/generator/base/idl_sorter.rb', line 19 def print @visited = [] sort.each { |node| print_node(node) } end |
#sort ⇒ Object
24 25 26 |
# File 'lib/watir-webdriver/generator/base/idl_sorter.rb', line 24 def sort tsort.reverse end |
#tsort_each_child(node, &blk) ⇒ Object
32 33 34 |
# File 'lib/watir-webdriver/generator/base/idl_sorter.rb', line 32 def tsort_each_child(node, &blk) @interfaces[node].each(&blk) end |
#tsort_each_node(&blk) ⇒ Object
28 29 30 |
# File 'lib/watir-webdriver/generator/base/idl_sorter.rb', line 28 def tsort_each_node(&blk) @interfaces.each_key(&blk) end |