acronym
- 1.0.0
- 1.1.6
- 1.2.6
- 2.0.3
- 2.1.0
- 2.2.1
- 2.3.8
- 3.0.0
- 3.0.9
- 3.1.0
- 3.2.1 (0)
- 3.2.8 (0)
- 3.2.13 (0)
- 4.0.2 (38)
- 4.1.8 (17)
- 4.2.1 (0)
- 4.2.7 (0)
- 4.2.9 (0)
- 5.0.0.1 (0)
- 5.1.7 (0)
- 5.2.3 (0)
- 6.0.0 (0)
- 6.1.3.1 (0)
- 6.1.7.7 (0)
- 7.0.0 (0)
- 7.1.3.2 (0)
- 7.1.3.4 (0)
- What's this?
acronym(word)
public
Specifies a new acronym. An acronym must be specified as it will appear in a camelized string. An underscore string that contains the acronym will retain the acronym when passed to `camelize`, `humanize`, or `titleize`. A camelized string that contains the acronym will maintain the acronym when titleized or humanized, and will convert the acronym into a non-delimited single lowercase word when passed to underscore.
Examples:
acronym 'HTML' titleize 'html' #=> 'HTML' camelize 'html' #=> 'HTML' underscore 'MyHTML' #=> 'my_html'
The acronym, however, must occur as a delimited unit and not be part of another word for conversions to recognize it:
acronym 'HTTP' camelize 'my_http_delimited' #=> 'MyHTTPDelimited' camelize 'https' #=> 'Https', not 'HTTPs' underscore 'HTTPS' #=> 'http_s', not 'https' acronym 'HTTPS' camelize 'https' #=> 'HTTPS' underscore 'HTTPS' #=> 'https'
Note: Acronyms that are passed to `pluralize` will no longer be recognized, since the acronym will not occur as a delimited unit in the pluralized result. To work around this, you must specify the pluralized form as an acronym as well:
acronym 'API' camelize(pluralize('api')) #=> 'Apis' acronym 'APIs' camelize(pluralize('api')) #=> 'APIs'
`acronym` may be used to specify any word that contains an acronym or otherwise needs to maintain a non-standard capitalization. The only restriction is that the word must begin with a capital letter.
Examples:
acronym 'RESTful' underscore 'RESTful' #=> 'restful' underscore 'RESTfulController' #=> 'restful_controller' titleize 'RESTfulController' #=> 'RESTful Controller' camelize 'restful' #=> 'RESTful' camelize 'restful_controller' #=> 'RESTfulController' acronym 'McDonald' underscore 'McDonald' #=> 'mcdonald' camelize 'mcdonald' #=> 'McDonald'