Inflector
Module | ejs |
Definition | class Inflector |
Inheritance | Inflector ![]() |
Inflector class to convert singular to plural and vice-versa.
The Inflector class emulates the Rails Inflector. See: http://api.rubyonrails.org/classes/ActiveSupport/Inflector.html.
Properties
Qualifiers | Property | Type | Description |
---|
Inflector Class Methods
Qualifiers | Method |
---|---|
static | addIrregular(singular: String, plural: String): Void |
Add a new irregular mapping. | |
static | addPlural(expr: RegExp, replacement: String): Void |
Add a new plural rule. | |
static | addSingular(expr: RegExp, replacement: String): Void |
Add a new singular rule. | |
static | addUncountable(expr: RegExp, replacement: String): Void |
Add a new uncountable rule. | |
static | toOrdinal(number: Number) |
Convert a number to an ordinal string. | |
static | toPlural(word: String): String |
Convert a singular word to its plural form. | |
static | toSingular(word) |
Convert a singular word to its plural form. |
Inflector Instance Methods
Qualifiers | Method |
---|
Method Detail
static toOrdinal(number: Number)
- Description
- Convert a number to an ordinal string.
- Parameters
number: Number To convert.
- Returns
- An ordinal string matching the number.
- Description
- Convert a singular word to its plural form.
- Parameters
word: String Word to transform.
- Returns
- The plural form of a word. Return the word if it can't be converted.
static toSingular(word)
- Description
- Convert a singular word to its plural form.
- Parameters
word Word to transform.
- Returns
- The plural form of a word. Return the word if it can't be converted.