Class: Carbon::Counter Private
- Inherits:
-
Object
- Object
- Carbon::Counter
- Defined in:
- lib/carbon/counter.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
A mutable counter for giving out incremental ids.
Instance Attribute Summary collapse
-
#value ⇒ ::Numeric
readonly
private
The value.
Instance Method Summary collapse
-
#increment ⇒ ::Numeric
private
Increments the counter by one, and returns the new value.
-
#initialize(value = 0) ⇒ Counter
constructor
private
Initialize the counter.
Constructor Details
#initialize(value = 0) ⇒ Counter
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Initialize the counter.
16 17 18 |
# File 'lib/carbon/counter.rb', line 16 def initialize(value = 0) @value = value end |
Instance Attribute Details
#value ⇒ ::Numeric (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
The value.
11 12 13 |
# File 'lib/carbon/counter.rb', line 11 def value @value end |
Instance Method Details
#increment ⇒ ::Numeric
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Increments the counter by one, and returns the new value.
23 24 25 |
# File 'lib/carbon/counter.rb', line 23 def increment @value += 1 end |