Method: Count.count_file

Defined in:
lib/count.rb

.count_file(file) ⇒ Object



38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/count.rb', line 38

def self.count_file(file)
	count = 0
	comment = 0
	open(file) do |file|
		while line = file.gets 
			count = count + 1

			begin
				line.strip!
			rescue => e
				p e
			end

			if line.index("//") == 0 || line.index("#") == 0 || line.index('/*') == 0 || line.index('*')
				comment += 1
			end
		end
	end
	[count, count - comment]
end