Class: Gloo::Core::ObjFinder
- Inherits:
-
Object
- Object
- Gloo::Core::ObjFinder
- Defined in:
- lib/gloo/core/obj_finder.rb
Class Method Summary collapse
-
.by_name(engine, name, container = nil) ⇒ Object
Find all objects in the given container that have the given name.
-
.by_type(engine, type, container = nil) ⇒ Object
Find all objects in the given container of a given type.
Class Method Details
.by_name(engine, name, container = nil) ⇒ Object
Find all objects in the given container that have the given name. If the container isn’t provided, root will be used.
This is a recursive function.
18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/gloo/core/obj_finder.rb', line 18 def self.by_name( engine, name, container = nil ) container = engine.heap.root if container.nil? arr = [] container.children.each do |o| arr << o if o.name == name arr += by_name( engine, name, o ) if o.child_count.positive? end return arr end |
.by_type(engine, type, container = nil) ⇒ Object
Find all objects in the given container of a given type. If the container isn’t provided, root will be used.
This is a recursive function.
36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/gloo/core/obj_finder.rb', line 36 def self.by_type( engine, type, container = nil ) container = engine.heap.root if container.nil? arr = [] container.children.each do |o| # puts "#{o.class.typename} == #{type}" arr << o if o.class.typename == type arr += by_type( engine, type, o ) if o.child_count.positive? end return arr end |