Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.ruby > #6688
| Newsgroups | comp.lang.ruby |
|---|---|
| Date | 2012-12-04 11:24 -0800 |
| References | <47B18B80.9090204@mailbox.swipnet.se> |
| Message-ID | <8f6226ce-4519-4e72-a3d1-e55637fcba45@googlegroups.com> (permalink) |
| Subject | Re: Getting class name without module |
| From | irio.musskopf@caixadeideias.com.br |
Em terça-feira, 12 de fevereiro de 2008 10h05min31s UTC-2, Jari Williamsson escreveu: > Is there a method available to get only the class name, without getting > the module name prior to it? Alternatively, to get the class name within > the current name space context? > > For example, self.class could return something like this: > MyModule::MyClass > (I would like to only get the "MyClass" part.) > > Or do I have to resort to string manipulation/regexps? > > > Best regards, > > Jari Williamsson Em terça-feira, 12 de fevereiro de 2008 10h05min31s UTC-2, Jari Williamsson escreveu: > Is there a method available to get only the class name, without getting > the module name prior to it? Alternatively, to get the class name within > the current name space context? > > For example, self.class could return something like this: > MyModule::MyClass > (I would like to only get the "MyClass" part.) > > Or do I have to resort to string manipulation/regexps? > > > Best regards, > > Jari Williamsson If you are using ActiveSupport: MyModule::MyClass.to_s.demodulize # => "MyClass"
Back to comp.lang.ruby | Previous | Next — Next in thread | Find similar | Unroll thread
Re: Getting class name without module irio.musskopf@caixadeideias.com.br - 2012-12-04 11:24 -0800 Re: Getting class name without module Robert Klemme <shortcutter@googlemail.com> - 2012-12-05 08:19 +0100
csiph-web