Class: AsyncFutures::Counter
- Inherits:
-
Object
- Object
- AsyncFutures::Counter
- Defined in:
- lib/async_futures/counter.rb
Overview
Simple counter. Useful to wrap with a SynchronizedDelegator.
Instance Attribute Summary collapse
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Instance Method Summary collapse
- #increment(amount = 1) ⇒ Object
-
#initialize(value = 0) ⇒ Counter
constructor
A new instance of Counter.
Constructor Details
#initialize(value = 0) ⇒ Counter
Returns a new instance of Counter.
9 10 11 |
# File 'lib/async_futures/counter.rb', line 9 def initialize(value = 0) @value = value end |
Instance Attribute Details
#value ⇒ Object (readonly)
Returns the value of attribute value.
7 8 9 |
# File 'lib/async_futures/counter.rb', line 7 def value @value end |
Instance Method Details
#increment(amount = 1) ⇒ Object
13 14 15 |
# File 'lib/async_futures/counter.rb', line 13 def increment(amount = 1) @value += amount end |