class Contender::Counter
Simplified interface to an atomic reference that acts as a counter
Public Class Methods
new(initial = 0)
click to toggle source
@return [undefined]
Calls superclass method
# File lib/contender/counter.rb, line 5 def initialize(initial = 0) super initial end
Public Instance Methods
decrement()
click to toggle source
Decrements the value of this counter by 1 @return [Integer] The new value of this counter
# File lib/contender/counter.rb, line 19 def decrement update do |count| count = count - 1 end end
increment()
click to toggle source
Increments the value of this counter by 1 @return [Integer] The new value of this counter
# File lib/contender/counter.rb, line 11 def increment update do |count| count = count + 1 end end
inspect()
click to toggle source
@return [String]
# File lib/contender/counter.rb, line 26 def inspect "#<Contender::Counter = #{value}>" end