I'm trying to use Ruby's grep function in a way similar to how I would use the grep command in Linux.

For instance, normally I would use the following shell command to find a line in a file based on a key word, then print the following three lines.

cat filename | grep -A3 keyword
How would I emulate this command in ruby? The Ruby API hasn't been very helpful in discussing the grep command.

If not grep in Ruby, perhaps rak can do this?