Class: NameError::message
Overview
:nodoc:
Class Method Summary collapse
-
._load(str) ⇒ Object
:nodoc:.
Instance Method Summary collapse
-
#==(obj2) ⇒ Object
:nodoc:.
-
#_dump(limit) ⇒ Object
:nodoc:.
-
#to_str ⇒ Object
:nodoc:.
Class Method Details
._load(str) ⇒ Object
:nodoc:
1339 1340 1341 1342 1343 |
# File 'error.c', line 1339
static VALUE
name_err_mesg_load(VALUE klass, VALUE str)
{
return str;
}
|
Instance Method Details
#==(obj2) ⇒ Object
:nodoc:
1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 |
# File 'error.c', line 1258
static VALUE
name_err_mesg_equal(VALUE obj1, VALUE obj2)
{
VALUE *ptr1, *ptr2;
int i;
if (obj1 == obj2) return Qtrue;
if (rb_obj_class(obj2) != rb_cNameErrorMesg)
return Qfalse;
TypedData_Get_Struct(obj1, VALUE, &name_err_mesg_data_type, ptr1);
TypedData_Get_Struct(obj2, VALUE, &name_err_mesg_data_type, ptr2);
for (i=0; i<NAME_ERR_MESG_COUNT; i++) {
if (!rb_equal(ptr1[i], ptr2[i]))
return Qfalse;
}
return Qtrue;
}
|
#_dump(limit) ⇒ Object
:nodoc:
1332 1333 1334 1335 1336 |
# File 'error.c', line 1332
static VALUE
name_err_mesg_dump(VALUE obj, VALUE limit)
{
return name_err_mesg_to_str(obj);
}
|
#to_str ⇒ Object
:nodoc:
1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 |
# File 'error.c', line 1278
static VALUE
name_err_mesg_to_str(VALUE obj)
{
VALUE *ptr, mesg;
TypedData_Get_Struct(obj, VALUE, &name_err_mesg_data_type, ptr);
mesg = ptr[NAME_ERR_MESG__MESG];
if (NIL_P(mesg)) return Qnil;
else {
struct RString s_str, d_str;
VALUE c, s, d = 0, args[4];
int state = 0, singleton = 0;
rb_encoding *usascii = rb_usascii_encoding();
#define FAKE_CSTR(v, str) rb_setup_fake_str((v), (str), rb_strlen_lit(str), usascii)
obj = ptr[NAME_ERR_MESG__RECV];
switch (obj) {
case Qnil:
d = FAKE_CSTR(&d_str, "nil");
break;
case Qtrue:
d = FAKE_CSTR(&d_str, "true");
break;
case Qfalse:
d = FAKE_CSTR(&d_str, "false");
break;
default:
d = rb_protect(rb_inspect, obj, &state);
if (state)
rb_set_errinfo(Qnil);
if (NIL_P(d) || RSTRING_LEN(d) > 65) {
d = rb_any_to_s(obj);
}
singleton = (RSTRING_LEN(d) > 0 && RSTRING_PTR(d)[0] == '#');
d = QUOTE(d);
break;
}
if (!singleton) {
s = FAKE_CSTR(&s_str, ":");
c = rb_class_name(CLASS_OF(obj));
}
else {
c = s = FAKE_CSTR(&s_str, "");
}
args[0] = QUOTE(rb_obj_as_string(ptr[NAME_ERR_MESG__NAME]));
args[1] = d;
args[2] = s;
args[3] = c;
mesg = rb_str_format(4, args, mesg);
}
return mesg;
}
|