How to use Method#to_ruby
»From the ruby part of the brain.
In Ruby, there’s a handy dandy way to get a string representation of a method.
hoktauri$ cat method_to_ruby.rb
def bacon
"chunky"
end
if $0 == __FILE__
require 'rubygems'
require 'ruby2ruby'
require 'parse_tree_extensions'
require 'pp'
pp method(:bacon).to_ruby
end
hoktauri$ ruby method_to_ruby.rb
"def bacon\n \"chunky\"\nend"
Uses the ruby2ruby and ParseTree gems.