Method: Janeway::Functions#parse_function_value
- Defined in:
- lib/janeway/functions/value.rb
#parse_function_value ⇒ Object
Parameters:
1. NodesType
Result:
ValueType
The value() function extension provides a way to convert an instance of NodesType to a value and make that available for further processing in the filter expression:
Its only argument is an instance of NodesType (possibly taken from a filter-query, as in the example above). The result is an instance of ValueType.
If the argument contains a single node, the result is the value of the node.
If the argument is the empty nodelist or contains multiple nodes, the result is Nothing.
Note: A singular query may be used anywhere where a ValueType is expected, so there is no need to use the value() function extension with a singular query.
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/janeway/functions/value.rb', line 29 def parse_function_value consume # function raise "expect group_start token, found #{current}" unless current.type == :group_start consume # ( # Read parameter parameters = [parse_function_parameter] raise Error, 'Too many parameters for value() function call' unless current.type == :group_end AST::Function.new('value', parameters) do |nodes| if nodes.is_a?(Array) && nodes.size == 1 nodes.first else :nothing end end end |