to_json (JSON::Ext::Generator::GeneratorMethods::Float)

    /*
     * call-seq: to_json(*)
     *
     * Returns a JSON string representation for this Float number.
     */
    static VALUE mFloat_to_json(int argc, VALUE *argv, VALUE self)
    {
        JSON_Generator_State *state = NULL;
        VALUE Vstate, rest, tmp;
        double value = RFLOAT(self)->value;
        rb_scan_args(argc, argv, "01*", &Vstate, &rest);
        if (!NIL_P(Vstate)) Data_Get_Struct(Vstate, JSON_Generator_State, state);
        if (isinf(value)) {
            if (!state || state->allow_nan) {
                return rb_funcall(self, i_to_s, 0);
            } else {
                tmp = rb_funcall(self, i_to_s, 0);
                rb_raise(eGeneratorError, "%u: %s not allowed in JSON", __LINE__, StringValueCStr(tmp));
            }
        } else if (isnan(value)) {
            if (!state || state->allow_nan) {
                return rb_funcall(self, i_to_s, 0);
            } else {
                tmp = rb_funcall(self, i_to_s, 0);
                rb_raise(eGeneratorError, "%u: %s not allowed in JSON", __LINE__, StringValueCStr(tmp));
            }
        } else {
            return rb_funcall(self, i_to_s, 0);
        }
    }