sonic-pi

https://github.com/sonic-pi-net/sonic-pi

C++

Code. Music. Live.

String#singularize

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

If the optional parameter +locale+ is specified,
the word will be singularized as a word of that language.
By default, this parameter is set to <tt>:en</tt>.
You must define your own inflection rules for languages other than English.

  'posts'.singularize            # => "post"
  'octopi'.singularize           # => "octopus"
  'sheep'.singularize            # => "sheep"
  'word'.singularize             # => "word"
  'the blue mailmen'.singularize # => "the blue mailman"
  'CamelOctopi'.singularize      # => "CamelOctopus"
  'leyes'.singularize(:es)       # => "ley"

Source | Google | Stack overflow

Edit

git clone [email protected]:sonic-pi-net/sonic-pi.git

cd sonic-pi

open app/server/ruby/vendor/activesupport-7.0.6/lib/active_support/core_ext/string/inflections.rb

Contribute

# Make a new branch

git checkout -b -your-name--update-docs-String-singularize-for-pr


# Commit to git

git add app/server/ruby/vendor/activesupport-7.0.6/lib/active_support/core_ext/string/inflections.rbgit commit -m "better docs for String#singularize"


# Open pull request

gem install hub # on a mac you can `brew install hub`

hub fork

git push <your name> -your-name--update-docs-String-singularize-for-pr

hub pull-request


# Celebrate!