From: Peter Hickman Date: 2011-07-28T00:04:17+09:00 Subject: Re: Counting lines of code in a ruby code file ignoring method code lines in the process Well this could be a bit of a cheat but you could put the code through a formatter which will indent the code to the same level and then when you encounter a 'def' with x leading spaces you know that the paired 'end' should also have x leading spaces (and be on a line by itself). Seems to be cheating but would probably work.