Class: Rjq::AST::Node
- Inherits:
-
Object
show all
- Defined in:
- lib/rjq/ast.rb
Direct Known Subclasses
ArrayLiteral, Assignment, BinaryOp, Binding, Break, CapturedFilter, Comma, Field, Foreach, Format, FunctionCall, Identity, If, Index, Iterate, Label, Literal, ObjectLiteral, Optional, Pipe, Program, Recurse, Reduce, ScopedDefinition, Slice, StringLiteral, Try, UnaryOp, Variable, BytecodeFilter
Instance Attribute Summary collapse
Instance Method Summary
collapse
Instance Attribute Details
#source_span ⇒ Object
Returns the value of attribute source_span.
48
49
50
|
# File 'lib/rjq/ast.rb', line 48
def source_span
@source_span
end
|
Instance Method Details
#assign_value(copy, input, context, value) ⇒ Object
71
72
73
74
|
# File 'lib/rjq/ast.rb', line 71
def assign_value(copy, input, context, value)
paths(input, context).each { |path| copy = Path.set(copy, path, value) }
copy
end
|
#eval(_input, _context) ⇒ Object
55
56
57
|
# File 'lib/rjq/ast.rb', line 55
def eval(_input, _context)
raise NotImplementedError, "#{self.class}#eval"
end
|
#invalid_path_message(result, _input, _context) ⇒ Object
67
68
69
|
# File 'lib/rjq/ast.rb', line 67
def invalid_path_message(result, _input, _context)
"Invalid path expression with result #{JSON::Dumper.dump(result, indent: nil)}"
end
|
#paths(_input, _context) ⇒ Object
63
64
65
|
# File 'lib/rjq/ast.rb', line 63
def paths(_input, _context)
raise TypeError, "#{self.class} is not a path expression"
end
|
#take(input, context, count) ⇒ Object
59
60
61
|
# File 'lib/rjq/ast.rb', line 59
def take(input, context, count)
eval(input, context).first(count)
end
|
#with_source_span(span) ⇒ Object
50
51
52
53
|
# File 'lib/rjq/ast.rb', line 50
def with_source_span(span)
@source_span = span
self
end
|