function rb_check_convert_type

VALUE rb_check_convert_type(VALUE val, int type, const char *tname, const char *method)

val.method を実行してクラス tname のインスタンスを返します。 val がメソッド method を持たなければ nil を返します。

type は、T_ARRAY, T_STRING などの構造体を表す ID です。 method の結果の型が type でなければ例外 TypeError が発生します。