Class: String

Inherits:
Object
  • Object
show all
Defined in:
lib/raketa_admin/sinatra_adapter.rb

Instance Method Summary collapse

Instance Method Details

#singularizeObject



7
8
9
10
11
12
13
14
15
16
17
# File 'lib/raketa_admin/sinatra_adapter.rb', line 7

def singularize
  return self if empty?

  case self
  when /(s|x|z|ch|sh)es$/ then self[0..-3]
  when /ies$/ then "#{self[0..-4]}y"
  when /ves$/ then "#{self[0..-4]}f"
  when /s$/ then self[0..-2]
  else self
  end
end