class JMESPath::Nodes::Map
Public Instance Methods
call(args)
click to toggle source
# File lib/jmespath/nodes/function.rb, line 196 def call(args) if args.count != 2 return maybe_raise Errors::InvalidArityError, "function map() expects two arguments" end if Nodes::Expression === args[0] expr = args[0] else return maybe_raise Errors::InvalidTypeError, "function map() expects the first argument to be an expression" end if Array === args[1] list = args[1] else return maybe_raise Errors::InvalidTypeError, "function map() expects the second argument to be an list" end list.map { |value| expr.eval(value) } end