There is no main method that currently directly uses keyword arguments, i.e. klass.instance_method(:method).parameters will never return :key for built-in classes.
You probably need to define a method that takes an argument, in this case a hash, and analyze it yourself. To do this, you can use rb_scan_args with the argument : to get Hash from the last argument (for example, dir_initialize ) or code similar to the OPTHASH_GIVEN_P macro (in array.c ). From the hash, you can use rb_get_kwargs to get the values ββyou need. I have not considered how to create an error for unrecognized keyword arguments if you wish. I think most basic methods do not perform this check (at least for now).
You could define your method in Ruby using keyword elements and call the internal C method from there. This will provide you with free unknown keys and the correct signature parameters .
I hope to improve this situation with a revised api to define methods in Ruby 2.2, which would make it more natural to use keyword arguments in C functions, among other things (see this question )
Marc-andrΓ© lafortune
source share