Module: JMESPath::Nodes::TypeChecker Private

Included in:
CompareBy, EndsWithFunction, MaxFunction, MinFunction, SortByFunction, SortFunction, StartsWithFunction, TypeFunction
Defined in:
lib/jmespath/nodes/function.rb

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

Constant Summary collapse

ARRAY_TYPE =

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.

0
BOOLEAN_TYPE =

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.

1
EXPRESSION_TYPE =

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.

2
NULL_TYPE =

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.

3
NUMBER_TYPE =

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.

4
OBJECT_TYPE =

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.

5
STRING_TYPE =

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.

6
TYPE_NAMES =

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.

{
  ARRAY_TYPE => 'array',
  BOOLEAN_TYPE => 'boolean',
  EXPRESSION_TYPE => 'expression',
  NULL_TYPE => 'null',
  NUMBER_TYPE => 'number',
  OBJECT_TYPE => 'object',
  STRING_TYPE => 'string'
}.freeze

Instance Method Summary collapse

Instance Method Details

#get_type(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.



50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'lib/jmespath/nodes/function.rb', line 50

def get_type(value)
  if value.respond_to?(:to_str)
    STRING_TYPE
  elsif value == true || value == false
    BOOLEAN_TYPE
  elsif value.nil?
    NULL_TYPE
  elsif value.is_a?(Numeric)
    NUMBER_TYPE
  elsif value.respond_to?(:to_hash) || value.is_a?(Struct)
    OBJECT_TYPE
  elsif value.respond_to?(:to_ary)
    ARRAY_TYPE
  elsif value.is_a?(Expression)
    EXPRESSION_TYPE
  end
end