Class: PMD::Counter

Inherits:
Object
  • Object
show all
Defined in:
lib/pmd/counter.rb

Instance Method Summary collapse

Constructor Details

#initializeCounter

Returns a new instance of Counter.



5
6
7
8
9
10
11
12
13
14
15
# File 'lib/pmd/counter.rb', line 5

def initialize
  @value = 0
  if File.exists? Config.counter_path
    File.open Config.counter_path, "r" do |file|
      file_value = file.read
      if file_value and file_value.to_i
        @value = file_value.to_i
      end
    end
  end
end

Instance Method Details

#increaseObject



27
28
29
30
# File 'lib/pmd/counter.rb', line 27

def increase
  @value = @value + 1
  write @value
end

#resetObject



22
23
24
25
# File 'lib/pmd/counter.rb', line 22

def reset
  @value = 0
  write @value
end

#valueObject



17
18
19
20
# File 'lib/pmd/counter.rb', line 17

def value
  # return current value
  return @value
end