# encoding: utf-8 # frozen_string_literal: true module Carbon # A mutable counter for giving out incremental ids. # # @api private class Counter # The value. # @return [::Numeric] attr_reader :value # Initialize the counter. # # @param value [::Numeric] The initial value of the counter. def initialize(value = 0) @value = value end # Increments the counter by one, and returns the new value. # # @return [::Numeric] def increment @value += 1 end end end