From: Colin Bartlett Date: 2011-01-13T13:09:29+09:00 Subject: Re: simple name of a class? On Thu, Jan 13, 2011 at 1:48 AM, Kedar Mhaswade wrote: > The name method of class Class returns the full name of a class (e.g. > ::). Is there a way to get just the simple > name? I couldn't see one defined here: http://www.ruby-doc.org/core/classes/Module.html#M000474 mod.name --> string Returns the name of the module mod. Returns nil for anonymous modules. http://www.ruby-doc.org/core/classes/Module.src/M000474.html /* * call-seq: * mod.name -> string * * Returns the name of the module mod. Returns nil for anonymous modules. */ VALUE rb_mod_name(VALUE mod) { VALUE path = classname(mod); if (!NIL_P(path)) return rb_str_dup(path); return path; } Perhaps something like: class Module def path_last_name() if (i = (r = name).rindex(':')) then r[0..i] = '' end r end end