Class: Cmdlet::Inflection::Singularize

Inherits:
BaseCmdlet
  • Object
show all
Defined in:
lib/cmdlet/inflection/singularize.rb

Overview

Singularize: The reverse of #pluralize, returns the singular form of a word in a string

Instance Method Summary collapse

Methods inherited from BaseCmdlet

#tokenizer

Instance Method Details

#call(value) ⇒ String

Returns plural value turned to singular value.

Parameters:

  • value (String)
    • value - value to singularized

Returns:

  • (String)

    plural value turned to singular value



11
12
13
14
15
16
17
# File 'lib/cmdlet/inflection/singularize.rb', line 11

def call(value)
  return '' if value.nil?

  value = value.to_s if value.is_a?(Symbol)

  value.singularize
end