class JMESPath::Nodes::LengthFunction
Public Instance Methods
call(args)
click to toggle source
# File lib/jmespath/nodes/function.rb, line 186 def call(args) if args.count == 1 value = args.first else return maybe_raise Errors::InvalidArityError, 'function length() expects one argument' end if value.respond_to?(:to_hash) value.to_hash.size elsif value.respond_to?(:to_ary) value.to_ary.size elsif value.respond_to?(:to_str) value.to_str.size else return maybe_raise Errors::InvalidTypeError, 'function length() expects string, array or object' end end