class JMESPath::Nodes::ToNumberFunction

Public Instance Methods

call(args) click to toggle source
# File lib/jmespath/nodes/function.rb, line 375
def call(args)
  if args.count == 1
    begin
      value = Float(args.first)
      Integer(value) === value ? value.to_i : value
    rescue
      nil
    end
  else
    return maybe_raise Errors::InvalidArityError, "function to_number() expects one argument"
  end
end