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 = [{/ies\z/i, "y"}, {/ves\z/i, "fe"}, {/([aeiou])ses\z/i, "\\1se"}, {/sses\z/i, "ss"}, {/([^s])ses\z/i, "\\1se"}, {/xes\z/i, "x"}, {/zes\z/i, "ze"}, {/ches\z/i, "ch"}, {/shes\z/i, "sh"}, {/s\z/i, ""}]

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]