API Reference

util.inflector Class

Description

Inflector.

Methods

classify

(str) String static

Creates a class name.

Parameters

Returns

dasherize

(str) String static

Replaces underscores with dashes in the string.

Parameters

Returns

foreignKey

(str, sep) String static

Creates a foreign key name from a class name. separate_class_name_and_id_with_underscore sets
whether the method should put ‘_’ between the name and ‘id’.

Parameters

Returns

humanize

(str) String static

Capitalizes the first word, turns underscores into spaces and strip a trailing “_id”.

Parameters

Returns

ordinal

(num) String static

Returns the suffix that should be added to a number to denote the position in
an ordered sequence such as 1st, 2nd, 3rd, 4th.

Parameters

Returns

ordinalize

(num) String static

Turns a number into an ordinal string used to denote the position in an ordered sequence
such as 1st, 2nd, 3rd, 4th.

Parameters

Returns

parameterize

(str) String static

Replaces special characters in a string so that it may be used as part of a ‘pretty’ URL.

Parameters

Returns

pluralize

(str) String static

Returns the plural form of the string.

Parameters

Returns

singularize

(str) String static

Returns the singular form of the string.

Parameters

Returns

singularize

(str, uppercase) String static

Converts the string to CamelCase.

Parameters

Returns

startcase

(str) String static

Capitalizes all the words.

Parameters

Returns

tableize

(str) String static

Creates a name of a table.

Parameters

Returns

titleize

(str) String static

Capitalizes all the words, except for articles, prepositions, and conjunctions.

titleize is also aliased as titlecase.

Parameters

Returns

underscore

(str) String static

Returns an underscored, lowercased form of the string.

Parameters

Returns