"Nick Sieger" <nicksieger / gmail.com> writes: > On 3/26/06, Gerald Preissler <Gerald.Preissler / gmx.de> wrote: >> >> If I have an instance of REXML::Element, is there a convenient way to >> get it's element name? > > > It's in the included REXML::Namespace module: > > http://ruby-doc.org/stdlib/libdoc/rexml/rdoc/classes/REXML/Namespace.html > > element.name How can one figure that out in pure Ruby? It's rather easy, once you know the trick. irb(main):002:0> require 'rexml/document' => true irb(main):003:0> REXML::Element.instance_method(:name) => #<UnboundMethod: REXML::Element(REXML::Namespace)#name> ^^^^^^^^^^^^^^^^ irb(main):004:0> REXML::Element.instance_method(:to_s) => #<UnboundMethod: REXML::Element(REXML::Node)#to_s> ^^^^^^^^^^^ So, if you *know* you can call a method foo on objects of class Bar, but just can't find it anywere, inspect Bar.instance_method :foo and you'll see the defining module. > Cheers, > /Nick -- Christian Neukirchen <chneukirchen / gmail.com> http://chneukirchen.org