Class: Handlebars::Helpers::StringFormatting::Singularize

Inherits:
BaseHelper
  • Object
show all
Defined in:
lib/handlebars/helpers/string_formatting/singularize.rb

Overview

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

Instance Method Summary collapse

Methods inherited from BaseHelper

#handlebars_helper, #parse_json, #struct_to_hash, #tokenizer, #wrapper

Instance Method Details

#parse(value) ⇒ String

Parse will reverse of #pluralize, returns the singular form of a word in a string

Examples:


puts Singularize.new.parse('names')

name

puts Singularize.new.parse('octopi')

octopus

Returns:

  • (String)

    plural value turned to singular value



27
28
29
30
31
# File 'lib/handlebars/helpers/string_formatting/singularize.rb', line 27

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

  value.singularize
end