For 3.x functions this is impossible as they do not have type information. (You would have to call each function with each data type and see if it fails. Or, you would have to parse the ruby code and then via static analysis of the ruby code try to determine if a data type is acceptable or not) = impossible.
For 4.x this is doable. You would first need to load all functions, then look them up. For the 4.x functions it is possible to get the signatures defined by the dispatchers, and you can thus calculate the acceptable data type(s). You can then use the TypeCalculator to compute the type of the argument (-100 in your example), and then check if the acceptable data type is assignable from the inferred data type (in the example an Integer[-100, -100]). When inferring the value you should use TypeCalculator.infer_set to get the richest possible inference. With this approach you may get false positives as functions may have a wider type than what is actually allowed (checked at runtime), or where there are additional constraints posed by invariant combinations of parameters. That can probably be ignored for this use case, you would simply see some methods that may not be applicable. For 3.x functions, if you were to include them in the list, you would have to include all of them as you cannot determine if they will work or not. That in turn is a problem since if you have stdlib included you would get all of those functions in every list, which would make the feature less valuable (lots of false entries). Best, - henrik -- Visit my Blog "Puppet on the Edge" http://puppet-on-the-edge.blogspot.se/ On Friday, July 29, 2016 at 9:49:43 PM UTC+2, Corey Osman wrote: > > Hi, > > I am curious what the best approach would be to get a list of puppet > functions that respond to a particular data type. > > I am looking to add a feature to the puppet-repl where tab complete would > work off of the . operator. > > Example: > > ‘-100’.<TAB> > abs > max > min > split > > > There is similar magic that occurs with the Ruby based PRY REPL except > Ruby already knows its methods due to object ancestors. > > > Corey > -- You received this message because you are subscribed to the Google Groups "Puppet Developers" group. To unsubscribe from this group and stop receiving emails from it, send an email to puppet-dev+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-dev/48c196a7-4c14-45bf-bf8f-4ed1e0347330%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.