Class: PPStats::Counter

Inherits:
Object
  • Object
show all
Defined in:
lib/pp-stats/counter.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeCounter

Returns a new instance of Counter.



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/pp-stats/counter.rb', line 5

def initialize
  @count = {
      :files                  => 0,
      :lines                  => 0,
      :max_lines              => 0,
      :max_file               => nil,
      :floor_lines            => nil,
      :floor_file             => nil,
      :commented_lines        => 0,
      :max_commented_lines    => 0,
      :max_commented_file     => '',
      :floor_commented_lines  => 0,
      :floor_commented_file   => nil,
  }
end

Instance Attribute Details

#countObject (readonly)

Returns the value of attribute count.



3
4
5
# File 'lib/pp-stats/counter.rb', line 3

def count
  @count
end

Instance Method Details

#adjust(file, lines, commented_lines) ⇒ Object



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/pp-stats/counter.rb', line 21

def adjust(file, lines, commented_lines)
  @count[:files] += 1
  @count[:lines] += lines
  if lines > @count[:max_lines]
    @count[:max_lines] += lines
    @count[:max_file] = file
  end
  @count[:commented_lines] += commented_lines
  if commented_lines > @count[:max_commented_lines]
    @count[:max_commented_lines] = commented_lines
    @count[:max_commented_file] = file
  end
  if commented_lines < @count[:floor_commented_lines] || @count[:floor_commented_lines] == 0
    @count[:floor_commented_lines] = commented_lines
    @count[:floor_commented_file] = file
  end

end