# ReverseEng an Object's methods?

**URL:** <https://www.ruby-forum.com/t/reverseeng-an-objects-methods/192115>\
**Category:** Ruby\
**Created:** [July 24, 2010, 2:09am UTC](https://www.ruby-forum.com/t/reverseeng-an-objects-methods/192115 "2010-07-24T02:09:09Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [July 24, 2010, 2:09am UTC](https://www.ruby-forum.com/t/reverseeng-an-objects-methods/192115/1 "2010-07-24T02:09:09Z")

</div>

Could there (ever) be a way to reverse engineer, (to code), an object’s  
methods?  
In the case where the object/module has been extended?  
Is this more possible with 1.9.n?

MarkT

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [July 24, 2010, 4:03am UTC](https://www.ruby-forum.com/t/reverseeng-an-objects-methods/192115/2 "2010-07-24T04:03:18Z")

</div>

On Jul 23, 2010, at 16:48 , Mark T wrote:

> Could there (ever) be a way to reverse engineer, (to code), an object’s methods?  
> In the case where the object/module has been extended?  
> Is this more possible with 1.9.n?

You can use ParseTree and ruby2ruby in 1.8 (only).

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [July 24, 2010, 4:37pm UTC](https://www.ruby-forum.com/t/reverseeng-an-objects-methods/192115/3 "2010-07-24T16:37:38Z")

</div>

Mark T wrote:

> Could there (ever) be a way to reverse engineer, (to code), an object’s  
> methods?  
> In the case where the object/module has been extended?  
> Is this more possible with 1.9.n?

Actually less possible since 1.9 doesn’t keep around the parse tree’s,  
but still quite do-able.

ex (ri\_for gem):

go.rb:

class A  
def go  
33  
end  
end  
require ‘rubygems’  
require ‘ri\_for’  
A.ri\_for :go

$ gem install ri\_for  
$ ruby go.rb

C:\dev\ruby\scene-skipper\>ruby go.rb  
at go.rb:2  
sig: A#go arity 0  
def go  
33  
end  
Original code signature: def go  
#parameters signature: go( [] )

Enjoy.  
-r
