Class: JMESPath::Nodes::Function Private

Inherits:
Node
  • Object
show all
Defined in:
lib/jmespath/nodes/function.rb

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Defined Under Namespace

Classes: FunctionName

Constant Summary collapse

FUNCTIONS =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

{}

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Node

#chains_with?, #hash_like?

Constructor Details

#initialize(children, options = {}) ⇒ Function

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of Function.



8
9
10
11
12
# File 'lib/jmespath/nodes/function.rb', line 8

def initialize(children, options = {})
  @children = children
  @options = options
  @disable_visit_errors = @options[:disable_visit_errors]
end

Class Method Details

.create(name, children, options = {}) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



14
15
16
17
18
19
20
# File 'lib/jmespath/nodes/function.rb', line 14

def self.create(name, children, options = {})
  if (type = FUNCTIONS[name])
    type.new(children, options)
  else
    raise Errors::UnknownFunctionError, "unknown function #{name}()"
  end
end

Instance Method Details

#optimizeObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



26
27
28
# File 'lib/jmespath/nodes/function.rb', line 26

def optimize
  self.class.new(@children.map(&:optimize), @options)
end

#visit(value) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



22
23
24
# File 'lib/jmespath/nodes/function.rb', line 22

def visit(value)
  call(@children.map { |child| child.visit(value) })
end