From: Harry Truax Date: 2011-07-27T21:24:16+09:00 Subject: Counting lines of code in a ruby code file while ignoring method code lines --001636c927451d594704a90c0a38 Content-Type: text/plain; charset=ISO-8859-1 Hello, I am writing a Ruby program that reads a ruby code file and counts the number of lines of code that are in the file. I do not want to count the number of lines of code in any methods that may be in the file. I can look for a line of code that begins with 'def' and I know that the method will have an 'end' on the last line, but I am trying to figure out how to not get the 'end' confused with other 'end's that may be inside the method itself, like 'end's associated with if statements and case statements as an example. I was thinking that once I see a 'def' starting a code line I would know that I am reading in a method, so I would increment an 'end' counter by 1. I would also increment the end counter each time I read a 'case' or an 'if', or any other expression that required it's own 'end'. Each time I would read an 'end' I would decrement the 'end' counter, and when it equals zero, I would know that I read in the entire method, then I could start counting code lines again. Any ideas would be greatly appreciated. Thanks! Harry Truax -- Harry Truax Phone: 315.463.8506 Email: htruax@stf.com 26 Corporate Circle East Syracuse, NY 13057 --001636c927451d594704a90c0a38--