Method: ActiveSupport::Inflector#singularize
- Defined in:
- lib/jinx/active_support/inflector.rb
#singularize(word) ⇒ Object
The reverse of pluralize, returns the singular form of a word in a string.
157 158 159 160 161 162 163 164 165 166 |
# File 'lib/jinx/active_support/inflector.rb', line 157 def singularize(word) result = word.to_s.dup if inflections.uncountables.include?(result.downcase) result else inflections.singulars.each { |(rule, replacement)| break if result.gsub!(rule, replacement) } result end end |