class Carbon::Counter

A mutable counter for giving out incremental ids.

@api private

Attributes

value[R]

The value. @return [::Numeric]

Public Class Methods

new(value = 0) click to toggle source

Initialize the counter.

@param value [::Numeric] The initial value of the counter.

# File lib/carbon/counter.rb, line 16
def initialize(value = 0)
  @value = value
end

Public Instance Methods

increment() click to toggle source

Increments the counter by one, and returns the new value.

@return [::Numeric]

# File lib/carbon/counter.rb, line 23
def increment
  @value += 1
end