From: Florian Gross Date: 2004-11-18T01:18:15+09:00 Subject: Re: assert Michael Neumann wrote: > How about this: > > def breakpoint > file, line_no = caller.first.split(':', 2) > reason = File.readlines(file)[line_no.to_i - 1]. > strip.sub(/^breakpoint\s+/, '') > p reason > # setup irb session etc. > end > > a = 4 > breakpoint unless a == 5 > > This extracts the "unless a == 5" out of the source file. Of course, > that does not work for evaled-code (unless the source-buffer is stored > somewhere and we could access it). I have extracted run-time information from the source code before (proc_source.rb -- it finds the source code of a lambda / lambdafied block) and while it is a nice technique I think the overhead would be too high in this case. (Plus it will not work with -e which is a minor annoyance.)