Module: Sevgi::Function::Pluralize
- Included in:
- Sevgi::Function
- Defined in:
- lib/sevgi/function/string.rb
Overview
English pluralization promoted to Sevgi::F. This module organizes the facade implementation; it is not a consumer mixin contract.
Instance Method Summary collapse
-
#pluralize(word) ⇒ String
Pluralizes an English word using a small built-in rule set.
Instance Method Details
#pluralize(word) ⇒ String
Pluralizes an English word using a small built-in rule set.
107 108 109 110 111 112 113 114 115 |
# File 'lib/sevgi/function/string.rb', line 107 def pluralize(word) result = word.to_s.dup return result if result.empty? || UNCOUNTABLES.key?(result) || PLURALS.key?(result) return IRREGULARS[result] if IRREGULARS.key?(result) RULES.each { |(rule, replacement)| break if result.sub!(rule, replacement) } result end |