/usr/lib/ruby/vendor_ruby/metriks/counter.rb is in ruby-metriks 0.9.9.6-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 | require 'atomic'
module Metriks
# Public: Counters are one of the simplest metrics whose only operations
# are increment and decrement.
class Counter
# Public: Initialize a new Counter.
def initialize
@count = Atomic.new(0)
end
# Public: Reset the counter back to 0
#
# Returns nothing.
def clear
@count.value = 0
end
# Public: Increment the counter.
#
# incr - The value to add to the counter.
#
# Returns nothing.
def increment(incr = 1)
@count.update { |v| v + incr }
end
# Public: Decrement the counter.
#
# decr - The value to subtract from the counter.
#
# Returns nothing.
def decrement(decr = 1)
@count.update { |v| v - decr }
end
# Public: The current count.
#
# Returns the count.
def count
@count.value
end
end
end
|