Method: Dry::Inflector#humanize
- Defined in:
- lib/dry/inflector.rb
#humanize(input) ⇒ String
Humanize a string
153 154 155 156 157 158 159 160 161 162 163 |
# File 'lib/dry/inflector.rb', line 153 def humanize(input) input = input.to_s result = inflections.humans.apply_to(input) result.delete_suffix!("_id") result.tr!("_", " ") match = /([^[:alnum:]])/.match(result) separator = match ? match[0] : DEFAULT_SEPARATOR result.split(separator).map.with_index { |word, index| inflections.acronyms.apply_to(word, capitalize: index.zero?) }.join(separator) end |