Class: Janeway::Interpreters::CurrentNodeInterpreter

Inherits:
Base
  • Object
show all
Defined in:
lib/janeway/interpreters/current_node_interpreter.rb

Overview

Interpets current node identifier. This applies the following selector to the input.

Constant Summary

Constants inherited from Base

Base::NOTHING

Instance Attribute Summary

Attributes inherited from Base

#next, #node

Instance Method Summary collapse

Methods inherited from Base

#as_json, #initialize, #selector, #to_s, #type

Constructor Details

This class inherits a constructor from Janeway::Interpreters::Base

Instance Method Details

#interpret(input, parent, root, _path) ⇒ Array

Apply selector to each value in the current node and return result.

The result is an Array containing all results of evaluating the CurrentNode’s selector (if any.)

If the selector extracted values from nodes such as strings, numbers or nil/null, these will be included in the array. If the selector did not match any node, the array may be empty. If there was no selector, then the current input node is returned in the array.

Parameters:

  • input (Array, Hash)

    the results of processing so far

  • parent (Array, Hash)

    parent of the input object

  • root (Array, Hash)

    the entire input

  • _path (Array)

    ignored

Returns:

  • (Array)

    Node List containing all results from evaluating this node’s selectors.



26
27
28
29
30
31
32
# File 'lib/janeway/interpreters/current_node_interpreter.rb', line 26

def interpret(input, parent, root, _path)
  if @next
    @next.interpret(input, parent, root, [])
  else
    input
  end
end