Inflector

Moduleejs
Definition class Inflector
InheritanceInflector inherit Object

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

QualifiersPropertyTypeDescription

Inflector Class Methods

QualifiersMethod
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

(No own instance methods defined)

QualifiersMethod

Method Detail

static addIrregular(singular: String, plural: String): Void
Description
Add a new irregular mapping.
Parameters
singular: String Singular word form.
plural: String Plural word form.

static addPlural(expr: RegExp, replacement: String): Void
Description
Add a new plural rule.
Parameters
expr: RegExp Regular expression to match.
replacement: String Regular expression replacement string.

static addSingular(expr: RegExp, replacement: String): Void
Description
Add a new singular rule.
Parameters
expr: RegExp Regular expression to match.
replacement: String Regular expression replacement string.

static addUncountable(expr: RegExp, replacement: String): Void
Description
Add a new uncountable rule.
Parameters
expr: RegExp Regular expression to match.
replacement: String Regular expression replacement string.

static toOrdinal(number: Number)
Description
Convert a number to an ordinal string.
Parameters
number: Number To convert.
Returns
An ordinal string matching the number.

static toPlural(word: String): String
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.