Ruby reflection of methods

If I do something like:
meth=method(:send) (or any other method)

is there anyway to get the actual text of the send method? like
meth.body or something?

I don’t actually need the text of the method, I was just wondering.

Ray

If I do something like:
meth=method(:send) (or any other method)

is there anyway to get the actual text of the send method? like
meth.body or something?

I don’t actually need the text of the method, I was just wondering.

There is such a way. Use the mighty and impressive Ruby2Ruby gem. It’s
downright scary.

teh IRB session:

class RedWine
def drink
“glug”
end
end
=> nil

@red_wine = RedWine.new
=> #RedWine:0x1108514

require ‘ruby2ruby’
=> true

@red_wine.method(:drink).to_ruby
=> “def drink\n “glug”\nend”


Giles B.

Podcast: http://hollywoodgrit.blogspot.com
Blog: http://gilesbowkett.blogspot.com
Portfolio: http://www.gilesgoatboy.org
Tumblelog: http://giles.tumblr.com

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs