Module: RubyUnderscore::EnhancerHelper
Defined Under Namespace
Classes: EnhancerDetector
Instance Method Summary
collapse
Instance Method Details
#assertSexpIs(sexp, type) ⇒ Object
65
66
67
|
# File 'lib/tree_converters.rb', line 65
def assertSexpIs(sexp, type)
raise "Wrong sexp type: #{sexp.first}" unless sexp.first == type
end
|
#chain(sexp, *processorClasses) ⇒ Object
39
40
41
42
43
|
# File 'lib/tree_converters.rb', line 39
def chain(sexp, *processorClasses)
processorClasses.inject(sexp) do |memo, clas|
clas.new.process memo
end
end
|
#clone(array) ⇒ Object
Deep Clone or arrays. Focused on arrays to be converted into sexp.
25
26
27
28
29
30
31
32
33
34
35
36
37
|
# File 'lib/tree_converters.rb', line 25
def clone(array)
a = []
array.each do | x |
a << if x.is_a? Array
clone(x)
elsif x.is_a? Symbol or x.is_a? Fixnum or x.is_a? Regexp
x
else
x.clone
end
end
a
end
|
#needsEnhancing(clas, method) ⇒ Object
45
46
47
|
# File 'lib/tree_converters.rb', line 45
def needsEnhancing(clas, method)
sexpNeedsEnhancing sexpOf clas, method
end
|
#sexpEnhancingCount(sexp) ⇒ Object
58
59
60
61
62
63
|
# File 'lib/tree_converters.rb', line 58
def sexpEnhancingCount(sexp)
return 0 if sexp.nil?
parser = EnhancerDetector.new
parser.process clone sexp
return parser.enhanceCount
end
|
#sexpNeedsEnhancing(sexp) ⇒ Object
54
55
56
|
# File 'lib/tree_converters.rb', line 54
def sexpNeedsEnhancing(sexp)
sexpEnhancingCount(sexp) > 0
end
|
#sexpOf(clas, method) ⇒ Object
50
51
52
|
# File 'lib/tree_converters.rb', line 50
def sexpOf(clas, method)
ParseTree.translate clas, method
end
|