You will have to write a (very limited) parser for Ruby. If your Ruby code is vaguely well-formed, you can likely get by by remembering what items you saw in a list and removing the items whenever you encounter an end:
my @stack; while (<RUBY_FILE>) { if (/^\s+def (.*)/) { push @stack, ['def',$1]; print; } elsif (/^\s+if (.*)/) { push @stack, ['if',$1]; print; } elsif (/^\s+end/) { my $block = pop @stack; if ($block->[0] eq 'def') { print "*** definition of $block->[1] ended\n"; }; } else { # collect, or do something else print; }; };
But this is not a script writing service. You need to do your own work. You have not shown a single line of the code that you tried.
In reply to Re^3: Extracting the Methods in a Ruby file
by Corion
in thread Extracting the Methods in a Ruby file
by thillai_selvan
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |