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
24
25
26
|
# File 'lib/sirop/finder.rb', line 24
def method_missing(sym, node, *args)
visit_child_nodes(node)
end
|
Class Method Details
.find ⇒ Object
7
8
9
|
# File 'lib/sirop/finder.rb', line 7
def self.find(*, &)
new.find(*, &)
end
|
Instance Method Details
#find(root, key) ⇒ Object
11
12
13
14
15
16
17
18
|
# File 'lib/sirop/finder.rb', line 11
def find(root, key, &)
instance_exec(&)
@key = key
catch(key) do
visit(root)
nil
end
end
|
#found!(node) ⇒ Object
20
21
22
|
# File 'lib/sirop/finder.rb', line 20
def found!(node)
throw(@key, node)
end
|