Skip to content

Instantly share code, notes, and snippets.

@BenHall
Created January 17, 2010 23:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save BenHall/279656 to your computer and use it in GitHub Desktop.
Save BenHall/279656 to your computer and use it in GitHub Desktop.
#http://stackoverflow.com/questions/2082741/ruby-block-to-string-instead-of-executing
require 'rubygems'
require 'parse_tree'
require 'parse_tree_extensions'
require 'ruby2ruby'
def block_as_string &block
puts block.to_ruby
block.to_ruby.gsub(/[{}]/, '').gsub(/proc/, '').strip
end
block_as_string {puts 'x'}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment