module Amber::Support::Inflector

Defined in:

amber/support/inflector.cr

Constant Summary

IRREGULARS = {"people" => "person", "men" => "man", "women" => "woman", "children" => "child", "mice" => "mouse", "geese" => "goose", "teeth" => "tooth", "feet" => "foot", "data" => "datum", "criteria" => "criterion", "media" => "medium", "analyses" => "analysis", "oxen" => "ox"}
SINGULAR_RULES = [SingularRule.new("ies", "y"), SingularRule.new("ves", "fe"), SingularRule.new("ses", "se", SingularRule::Preceding::Vowel), SingularRule.new("sses", "ss"), SingularRule.new("ses", "se", SingularRule::Preceding::AnythingButS), SingularRule.new("xes", "x"), SingularRule.new("zes", "ze"), SingularRule.new("ches", "ch"), SingularRule.new("shes", "sh"), SingularRule.new("s", "")]

Rules ordered from most specific to least specific

Class Method Summary

Class Method Detail

def self.namespace_to_prefix(namespace : String) : String #

Converts a singular English word to a simple prefix-friendly form. Used to generate route name prefixes from namespace paths. Strips leading/trailing slashes and replaces inner slashes with underscores.


[View source]
def self.singularize(word : String) : String #

Converts a plural English word to its singular form. Handles common English plural patterns. For edge cases, developers can override with the explicit as: parameter.


[View source]