Method: CodeStats::Stats#initialize
- Defined in:
- lib/code_stats.rb
#initialize(file) ⇒ Stats
Returns a new instance of Stats.
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/code_stats.rb', line 12 def initialize(file) @file = file @lines, @comments, @empty = 0, 0, 0 File.open(file).each_line do |line| @lines += 1 case line when /^\s*$/ @empty += 1 when /^\s*#/ @comments += 1 end end end |