Module: I18nliner::Extractors::SexpHelper
Defined Under Namespace
Classes: UnsupportedExpression
Instance Method Summary
collapse
Instance Method Details
#raw(exp) ⇒ Object
15
16
17
18
|
# File 'lib/i18nliner/extractors/sexp_helper.rb', line 15
def raw(exp)
exp.shift
return exp.shift
end
|
#string_concatenation?(exp) ⇒ Boolean
8
9
10
11
12
13
|
# File 'lib/i18nliner/extractors/sexp_helper.rb', line 8
def string_concatenation?(exp)
exp.sexp_type == :call &&
exp[2] == :+ &&
exp.last &&
exp.last.sexp_type == :str
end
|
#string_from(exp) ⇒ Object
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
# File 'lib/i18nliner/extractors/sexp_helper.rb', line 20
def string_from(exp)
return raw(exp) if exp.sexp_type == :str
exp.shift
lhs = exp.shift
exp.shift
rhs = exp.shift
if lhs.sexp_type == :str
lhs.last + rhs.last
elsif stringish?(lhs)
string_from(lhs) + rhs.last
else
process(lhs)
UnsupportedExpression
end
end
|
#stringish?(exp) ⇒ Boolean
4
5
6
|
# File 'lib/i18nliner/extractors/sexp_helper.rb', line 4
def stringish?(exp)
exp && (exp.sexp_type == :str || string_concatenation?(exp))
end
|