Class: Sirop::Finder
- Inherits:
-
Prism::BasicVisitor
- Object
- Prism::BasicVisitor
- Sirop::Finder
show all
- Defined in:
- lib/sirop/finder.rb
Class Method Summary
collapse
Instance Method Summary
collapse
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(sym, node, *args) ⇒ Object
25
26
27
|
# File 'lib/sirop/finder.rb', line 25
def method_missing(sym, node, *args)
visit_child_nodes(node)
end
|
Class Method Details
.find ⇒ Object
7
8
9
10
|
# File 'lib/sirop/finder.rb', line 7
def self.find(*, &)
finder = self.new
finder.find(*, &)
end
|
Instance Method Details
#find(root, key) ⇒ Object
12
13
14
15
16
17
18
19
|
# File 'lib/sirop/finder.rb', line 12
def find(root, key, &)
instance_exec(&)
@key = key
catch(key) do
visit(root)
nil
end
end
|
#found!(node) ⇒ Object
21
22
23
|
# File 'lib/sirop/finder.rb', line 21
def found!(node)
throw(@key, node)
end
|