Class: JSONP3::Length

Inherits:
FunctionExtension show all
Defined in:
lib/json_p3/function_extensions/length.rb

Overview

The standard length function.

Constant Summary collapse

ARG_TYPES =
[:value_expression].freeze
RETURN_TYPE =
:value_expression

Instance Method Summary collapse

Instance Method Details

#call(obj) ⇒ Object



11
12
13
14
15
# File 'lib/json_p3/function_extensions/length.rb', line 11

def call(obj)
  return :nothing unless obj.is_a?(Array) || obj.is_a?(Hash) || obj.is_a?(String)

  obj.length
end