#!/bin/sh -e
#
#/ Usage: lsrb <file>...
#/ lsrb - list class, module, and method definitions in Ruby <file>

# show usage
[ -z "$1" ] || [ "$1" = "-h" ] || [ "$1" = "--help" ] && {
  grep ^#/ <"$0" | cut -c4-
  exit 2
}

# run over files and grep out interesting bits
for f in "$@"; do
  echo "${f}:"
  grep -e '^[  ]*\(class\|module\|def\|alias\|alias_method\|private\)\(\s\|$\)' "${f}" \
    | sed 's/^/  /'
done
