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) ⇒ 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
# File 'lib/jmespath/nodes/function.rb', line 8

def initialize(children)
  @children = children
end

Class Method Details

.create(name, children) ⇒ 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.



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

def self.create(name, children)
  if (type = FUNCTIONS[name])
    type.new(children)
  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.



24
25
26
# File 'lib/jmespath/nodes/function.rb', line 24

def optimize
  self.class.new(@children.map(&:optimize))
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.



20
21
22
# File 'lib/jmespath/nodes/function.rb', line 20

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