2023-02-22 20:59:05 -08:00
|
|
|
# typed: strict
|
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module Utils
|
|
|
|
# Inflection utility methods, as a lightweight alternative to `ActiveSupport::Inflector``.
|
|
|
|
#
|
|
|
|
# @api private
|
|
|
|
module Inflection
|
|
|
|
extend T::Sig
|
|
|
|
|
2023-02-23 12:14:37 -08:00
|
|
|
# Combines `stem` with the `singular` or `plural` suffix based on `count`.
|
|
|
|
sig { params(stem: String, count: Integer, plural: String, singular: String).returns(String) }
|
|
|
|
def self.pluralize(stem, count, plural: "s", singular: "")
|
2023-02-22 20:59:05 -08:00
|
|
|
suffix = (count == 1) ? singular : plural
|
|
|
|
"#{stem}#{suffix}"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|