Class: Riak::Crdt::BatchCounter
- Defined in:
- lib/riak/crdt/batch_counter.rb
Instance Attribute Summary collapse
-
#accumulator ⇒ Object
readonly
Returns the value of attribute accumulator.
Instance Method Summary collapse
- #decrement(amount = 1) ⇒ Object
- #increment(amount = 1) ⇒ Object
-
#initialize ⇒ BatchCounter
constructor
A new instance of BatchCounter.
Constructor Details
#initialize ⇒ BatchCounter
Returns a new instance of BatchCounter.
6 7 8 |
# File 'lib/riak/crdt/batch_counter.rb', line 6 def initialize @accumulator = 0 end |
Instance Attribute Details
#accumulator ⇒ Object (readonly)
Returns the value of attribute accumulator.
4 5 6 |
# File 'lib/riak/crdt/batch_counter.rb', line 4 def accumulator @accumulator end |
Instance Method Details
#decrement(amount = 1) ⇒ Object
14 15 16 |
# File 'lib/riak/crdt/batch_counter.rb', line 14 def decrement(amount = 1) increment -amount end |
#increment(amount = 1) ⇒ Object
10 11 12 |
# File 'lib/riak/crdt/batch_counter.rb', line 10 def increment(amount = 1) @accumulator += amount end |