class Proc
def to_method
def to_method name = ProcStoreTmp.name ProcStoreTmp.send(:define_method, name, self) ProcStoreTmp.new.method(name) end
def to_ruby
def to_ruby ruby = self.to_method.to_ruby ruby.sub!(/\A(def \S+)\(([^\)]*)\)/, '\1 |\2|') # move args ruby.sub!(/\Adef[^\n\|]+/, 'proc { ') # strip def name ruby.sub!(/end\Z/, '}') # strip end ruby.gsub!(/\s+$/, '') # trailing WS bugs me ruby end
def to_sexp
def to_sexp body = self.to_method.to_sexp[2][1..-1] [:proc, *body] end