Skip to content
No description, website, or topics provided.
Crystal
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.

Files

Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
spec
src
.editorconfig
.gitignore
.travis.yml
LICENSE
README.md
shard.yml

README.md

Inflector

Installation

  1. Add the dependency to your shard.yml:

    dependencies:
      cadmium_inflector:
        github: cadmiumcr/inflector
  2. Run shards install

Usage

require "cadmium_inflector"

Nouns

Nouns can be inflected using the NounInflector which has also been attached to the String class.

inflector = Cadmium.noun_inflector.new

inflector.pluralize("radius")
# => radii

inflector.singularize("radii")
# => radius

"person".pluralize
# => people

"people".singularize
# => person

Present Tense Verbs

Present tense verbs can be inflected with the PresentVerbInflector. This has also been attached to the string class.

inflector = Cadmium.present_verb_inflector.new

inflector.singularize("become")
# => became

inflector.pluralize("became")
# => become

"walk".singularize(false) # noun: false
# => walks

"walks".pluralize(false)  # noun: false
# => walk

Numbers

Numbers can be inflected with the CountInflector which also adds a method to_nth to the Int class.

Cadmium.count_inflector.nth(1)
# => 1st

Cadmium.count_inflector.nth(111)
# => 111th

153.to_nth
# => 153rd

Contributing

  1. Fork it (https://github.com/your-github-user/cadmium_inflectors/fork)
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

Contributors

You can’t perform that action at this time.