Class: FilterTable::Trace
- Inherits:
-
Object
- Object
- FilterTable::Trace
show all
- Defined in:
- lib/utils/filter.rb
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize ⇒ Trace
10
11
12
|
# File 'lib/utils/filter.rb', line 10
def initialize
@chain = []
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(*args) ⇒ Object
22
23
24
25
26
|
# File 'lib/utils/filter.rb', line 22
def method_missing(*args)
res = Trace.new
@chain.push([args, res])
res
end
|
Class Method Details
.to_ruby(trace) ⇒ Object
28
29
30
31
32
33
34
35
36
37
38
39
|
# File 'lib/utils/filter.rb', line 28
def self.to_ruby(trace)
chain = trace.instance_variable_get(:@chain)
return '' if chain.empty?
' ' + chain.map do |el|
m = el[0][0]
args = el[0].drop(1)
nxt = to_ruby(el[1])
next m.to_s + nxt if args.empty?
next m.to_s + ' ' + args[0].inspect + nxt if args.length == 1
m.to_s + '(' + args.map(&:inspect).join(', ') + ')' + nxt
end.join(' ')
end
|