Introduced several common ruby idioms

Most notably the '||=' notation to check a value or set it if it is nil, and the use of "inject".
I also used a little helper method to remove a lot of redundancy from the patterns file, and stuck to ruby naming conventions such as 'method' instead of 'getMethod'.

If I have some more time, I'll adapt the "test" file to use standard ruby testing methods, and maybe create a branch that uses treetop for something more robust.

Note that the things I changed or suggested are not necessarily "the best" or even "correct" (output shows an errant h3 tag?" but do demonstrate things you will see elsewhere in Ruby, and in some cases certainly saved many lines of code!