Class: NameError::message

Inherits:
Data show all
Defined in:
error.c

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.!Object

:nodoc:



# File 'error.c'

/* :nodoc: */
static VALUE
name_err_mesg_new(obj, mesg, recv, method)
    VALUE obj, mesg, recv, method;
{
    VALUE *ptr = ALLOC_N(VALUE, 3);

    ptr[0] = mesg;
    ptr[1] = recv;
    ptr[2] = method;
    return Data_Wrap_Struct(rb_cNameErrorMesg, name_err_mesg_mark, -1, ptr);
}

._loadObject

:nodoc:



# File 'error.c'

/* :nodoc: */
static VALUE
name_err_mesg_load(klass, str)
    VALUE klass, str;
{
    return str;
}

Instance Method Details

#_dumpObject

:nodoc:



# File 'error.c'

/* :nodoc: */
static VALUE
name_err_mesg_to_str(obj)
    VALUE obj;
{
    VALUE *ptr, mesg;
    Data_Get_Struct(obj, VALUE, ptr);

    mesg = ptr[0];
    if (NIL_P(mesg)) return Qnil;
    else {
    const char *desc = 0;
    VALUE d = 0, args[3];

    obj = ptr[1];
    switch (TYPE(obj)) {
      case T_NIL:
        desc = "nil";
        break;
      case T_TRUE:
        desc = "true";
        break;
      case T_FALSE:
        desc = "false";
        break;
      default:
        d = rb_protect(rb_inspect, obj, 0);
        if (NIL_P(d) || RSTRING(d)->len > 65) {
        d = rb_any_to_s(obj);
        }
        desc = RSTRING(d)->ptr;
        break;
    }
    if (desc && desc[0] != '#') {
        d = rb_str_new2(desc);
        rb_str_cat2(d, ":");
        rb_str_cat2(d, rb_obj_classname(obj));
    }
    args[0] = mesg;
    args[1] = ptr[2];
    args[2] = d;
    mesg = rb_f_sprintf(3, args);
    }
    if (OBJ_TAINTED(obj)) OBJ_TAINT(mesg);
    return mesg;
}

#to_strObject

:nodoc:



# File 'error.c'

/* :nodoc: */
static VALUE
name_err_mesg_to_str(obj)
    VALUE obj;
{
    VALUE *ptr, mesg;
    Data_Get_Struct(obj, VALUE, ptr);

    mesg = ptr[0];
    if (NIL_P(mesg)) return Qnil;
    else {
    const char *desc = 0;
    VALUE d = 0, args[3];

    obj = ptr[1];
    switch (TYPE(obj)) {
      case T_NIL:
        desc = "nil";
        break;
      case T_TRUE:
        desc = "true";
        break;
      case T_FALSE:
        desc = "false";
        break;
      default:
        d = rb_protect(rb_inspect, obj, 0);
        if (NIL_P(d) || RSTRING(d)->len > 65) {
        d = rb_any_to_s(obj);
        }
        desc = RSTRING(d)->ptr;
        break;
    }
    if (desc && desc[0] != '#') {
        d = rb_str_new2(desc);
        rb_str_cat2(d, ":");
        rb_str_cat2(d, rb_obj_classname(obj));
    }
    args[0] = mesg;
    args[1] = ptr[2];
    args[2] = d;
    mesg = rb_f_sprintf(3, args);
    }
    if (OBJ_TAINTED(obj)) OBJ_TAINT(mesg);
    return mesg;
}