Class: NameError::message
Do not use. This class is for internal use only.
Class Method Summary
Instance Method Summary
Class Method Details
._load(str)
[ GitHub ]# File 'error.c', line 2597
static VALUE name_err_mesg_load(VALUE klass, VALUE str) { return str; }
Instance Method Details
#==(obj2)
[ GitHub ]# File 'error.c', line 2463
static VALUE name_err_mesg_equal(VALUE obj1, VALUE obj2) { if (obj1 == obj2) return Qtrue; if (rb_obj_class(obj2) != rb_cNameErrorMesg) return Qfalse; name_error_message_t *ptr1, *ptr2; TypedData_Get_Struct(obj1, name_error_message_t, &name_err_mesg_data_type, ptr1); TypedData_Get_Struct(obj2, name_error_message_t, &name_err_mesg_data_type, ptr2); if (!rb_equal(ptr1->mesg, ptr2->mesg)) return Qfalse; if (!rb_equal(ptr1->recv, ptr2->recv)) return Qfalse; if (!rb_equal(ptr1->name, ptr2->name)) return Qfalse; return Qtrue; }
#_dump(limit)
[ GitHub ]# File 'error.c', line 2590
static VALUE name_err_mesg_dump(VALUE obj, VALUE limit) { return name_err_mesg_to_str(obj); }
#initialize_copy(obj2)
[ GitHub ]# File 'error.c', line 2446
static VALUE name_err_mesg_init_copy(VALUE obj1, VALUE obj2) { if (obj1 == obj2) return obj1; rb_obj_init_copy(obj1, obj2); name_error_message_t *ptr1, *ptr2; TypedData_Get_Struct(obj1, name_error_message_t, &name_err_mesg_data_type, ptr1); TypedData_Get_Struct(obj2, name_error_message_t, &name_err_mesg_data_type, ptr2); RB_OBJ_WRITE(obj1, &ptr1->mesg, ptr2->mesg); RB_OBJ_WRITE(obj1, &ptr1->recv, ptr2->recv); RB_OBJ_WRITE(obj1, &ptr1->name, ptr2->name); return obj1; }
#to_str
[ GitHub ]# File 'error.c', line 2493
static VALUE name_err_mesg_to_str(VALUE obj) { name_error_message_t *ptr; TypedData_Get_Struct(obj, name_error_message_t, &name_err_mesg_data_type, ptr); VALUE mesg = ptr->mesg; if (NIL_P(mesg)) return Qnil; else { struct RString s_str, c_str, d_str; VALUE c, s, d = 0, args[4], c2; int state = 0; rb_encoding *usascii = rb_usascii_encoding(); #define FAKE_CSTR(v, str) rb_setup_fake_str((v), (str), rb_strlen_lit(str), usascii) c = s = FAKE_CSTR(&s_str, ""); obj = ptr->recv; switch (obj) { case Qnil: c = d = FAKE_CSTR(&d_str, "nil"); break; case Qtrue: c = d = FAKE_CSTR(&d_str, "true"); break; case Qfalse: c = d = FAKE_CSTR(&d_str, "false"); break; default: if (strstr(RSTRING_PTR(mesg), "%2$s")) { d = rb_protect(name_err_mesg_receiver_name, obj, &state); if (state || NIL_OR_UNDEF_P(d)) d = rb_protect(rb_inspect, obj, &state); if (state) { rb_set_errinfo(Qnil); } d = rb_check_string_type(d); if (NIL_P(d)) { d = rb_any_to_s(obj); } } if (!RB_SPECIAL_CONST_P(obj)) { switch (RB_BUILTIN_TYPE(obj)) { case T_MODULE: s = FAKE_CSTR(&s_str, "module "); c = obj; break; case T_CLASS: s = FAKE_CSTR(&s_str, "class "); c = obj; break; default: goto object; } } else { VALUE klass; object: klass = CLASS_OF(obj); if (RB_TYPE_P(klass, T_CLASS) && RCLASS_SINGLETON_P(klass)) { s = FAKE_CSTR(&s_str, ""); if (obj == rb_vm_top_self()) { c = FAKE_CSTR(&c_str, "main"); } else { c = rb_any_to_s(obj); } break; } else { s = FAKE_CSTR(&s_str, "an instance of "); c = rb_class_real(klass); } } c2 = rb_protect(name_err_mesg_receiver_name, c, &state); if (state || NIL_OR_UNDEF_P(c2)) c2 = rb_protect(rb_inspect, c, &state); if (state) { rb_set_errinfo(Qnil); } c2 = rb_check_string_type(c2); if (NIL_P(c2)) { c2 = rb_any_to_s(c); } c = c2; break; } args[0] = rb_obj_as_string(ptr->name); args[1] = d; args[2] = s; args[3] = c; mesg = rb_str_format(4, args, mesg); } return mesg; }