Class: PMD::Counter
- Inherits:
-
Object
- Object
- PMD::Counter
- Defined in:
- lib/pmd/counter.rb
Instance Method Summary collapse
- #increase ⇒ Object
-
#initialize ⇒ Counter
constructor
A new instance of Counter.
- #reset ⇒ Object
- #value ⇒ Object
Constructor Details
#initialize ⇒ Counter
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
#increase ⇒ Object
27 28 29 30 |
# File 'lib/pmd/counter.rb', line 27 def increase @value = @value + 1 write @value end |
#reset ⇒ Object
22 23 24 25 |
# File 'lib/pmd/counter.rb', line 22 def reset @value = 0 write @value end |
#value ⇒ Object
17 18 19 20 |
# File 'lib/pmd/counter.rb', line 17 def value # return current value return @value end |