Class: Rjq::AST::Pipe
Instance Attribute Summary collapse
-
#left ⇒ Object
readonly
Returns the value of attribute left.
-
#right ⇒ Object
readonly
Returns the value of attribute right.
Attributes inherited from Node
Instance Method Summary collapse
- #eval(input, context) ⇒ Object
-
#initialize(left, right) ⇒ Pipe
constructor
A new instance of Pipe.
- #paths(input, context) ⇒ Object
Methods inherited from Node
#assign_value, #invalid_path_message, #take, #with_source_span
Constructor Details
#initialize(left, right) ⇒ Pipe
Returns a new instance of Pipe.
303 304 305 306 |
# File 'lib/rjq/ast.rb', line 303 def initialize(left, right) @left = left @right = right end |
Instance Attribute Details
#left ⇒ Object (readonly)
Returns the value of attribute left.
301 302 303 |
# File 'lib/rjq/ast.rb', line 301 def left @left end |
#right ⇒ Object (readonly)
Returns the value of attribute right.
301 302 303 |
# File 'lib/rjq/ast.rb', line 301 def right @right end |
Instance Method Details
#eval(input, context) ⇒ Object
308 309 310 311 312 313 314 315 316 317 318 |
# File 'lib/rjq/ast.rb', line 308 def eval(input, context) out = [] @left.eval(input, context).each do |value| out.concat(@right.eval(value, context)) rescue ErrorValue => e raise ErrorValue.new(e.value, outputs: out + (e.outputs || [])) rescue BreakSignal => e raise BreakSignal.new(e.label, e.value, outputs: out + (e.outputs || [])) end out end |
#paths(input, context) ⇒ Object
320 321 322 323 324 325 326 327 |
# File 'lib/rjq/ast.rb', line 320 def paths(input, context) @left.paths(input, context).flat_map do |path| value = Path.get(input, path) @right.paths(value, context).map { |suffix| path + suffix } end rescue InvalidPathError => e raise InvalidPathError.new(@right.(e.result, input, context), e.result) end |