From: Harry Ohlsen Date: 2001-12-12T08:03:47+09:00 Subject: [ruby-talk:28286] Re: rdefs : a puny doc tool In article <60D4BD663C99D311A83D00805FA65D24271F14@IDMC>, "Issac Trotts" wrote: > # print out a brief summary of a ruby file. > > while gets > print if /(def|class|module)/ > end > Very simple and useful! I got a warning, though, saying it was using a constant Regexp in a test. Here's a slightly modified version, that fixes that, gives me less false positives (by only matching those keywords after any whitespace at the start of a line) and also reads from a file given on the command line, if provided: #!/usr/bin/env ruby if ARGV.length > 0 $stdin = File.new(ARGV[0]) end while gets print if $_ =~ /^\s*(def|class|module)/ end