Class: EnumerableExpessionEvaluator
Instance Method Summary
collapse
#initialize, #visit_arg, #visit_float, #visit_integer, #visit_statements, #visit_string, #visit_stringcontent, #visit_symbol, #visit_unary, #visit_variable
Instance Method Details
#visit_argslist(node) ⇒ Object
19
20
21
|
# File 'lib/providers/enumerable_expression_evaluator.rb', line 19
def visit_argslist(node)
node.map {|arg| arg.visit(self)}
end
|
#visit_binary(node) ⇒ Object
23
24
25
26
27
28
29
30
31
32
33
|
# File 'lib/providers/enumerable_expression_evaluator.rb', line 23
def visit_binary(node)
right_val = node.right.visit(self)
left_val = node.left.visit(self)
if node.operator.to_sym == :and
left_val && right_val
elsif node.operator.to_sym == :or
left_val || right_val
else
left_val.send(node.operator.to_ruby.to_sym, right_val)
end
end
|
#visit_call(node) ⇒ Object
35
36
37
38
39
40
41
42
43
44
|
# File 'lib/providers/enumerable_expression_evaluator.rb', line 35
def visit_call(node)
target = node.target.visit(self)
method_name = node.identifier ? node.identifier.to_sym : :[]
if (node.arguments)
arguments = node.arguments.collect { |x| x.visit(self) }
target.send(method_name, *arguments)
else
target.send(method_name)
end
end
|
#visit_groupby(node) ⇒ Object
5
6
7
|
# File 'lib/providers/enumerable_expression_evaluator.rb', line 5
def visit_groupby(node)
node.expression.visit(self)
end
|
#visit_hash(node) ⇒ Object
9
10
11
12
13
14
15
16
17
|
# File 'lib/providers/enumerable_expression_evaluator.rb', line 9
def visit_hash(node)
record = OpenStruct.new
node.elements.each do |e|
key = e.key.visit(self)
value = e.value.visit(self)
record.send("#{key.to_s}=".to_sym,value)
end
record
end
|