Inflections
public struct Inflections
A type that controls GRDB string inflections.
-
Undocumented
Declaration
Swift
public init()
-
Appends a pluralization rule.
var inflections = Inflections() inflections.plural("$", "s") inflections.pluralize("player") // "players"
Declaration
Swift
public mutating func plural( _ pattern: String, options: NSRegularExpression.Options = [.caseInsensitive], _ template: String)
Parameters
pattern
A regular expression pattern.
options
Regular expression options (defaults to
[.caseInsensitive]
).template
A replacement template string.
-
Appends a singularization rule.
var inflections = Inflections() inflections.singular("s$", "") inflections.singularize("players") // "player"
Declaration
Swift
public mutating func singular( _ pattern: String, options: NSRegularExpression.Options = [.caseInsensitive], _ template: String)
Parameters
pattern
A regular expression pattern.
options
Regular expression options (defaults to
[.caseInsensitive]
).template
A replacement template string.
-
Appends uncountable words.
var inflections = Inflections() inflections.plural("$", "s") inflections.uncountableWords(["foo"]) inflections.pluralize("foo") // "foo" inflections.pluralize("bar") // "bars"
Declaration
Swift
public mutating func uncountableWords(_ words: [String])
-
Appends an irregular singular/plural pair.
var inflections = Inflections() inflections.plural("$", "s") inflections.irregularSuffix("man", "men") inflections.pluralize("man") // "men" inflections.singularizes("women") // "woman"
Declaration
Swift
public mutating func irregularSuffix(_ singular: String, _ plural: String)
Parameters
singular
The singular form.
plural
The plural form.
-
Returns a pluralized string.
Inflections.default.pluralize("player") // "players"
Declaration
Swift
public func pluralize(_ string: String) -> String
-
Returns a singularized string.
Declaration
Swift
public func singularize(_ string: String) -> String
-
The default inflections
Declaration
Swift
public static var `default`: Inflections