- case_transform2 * Why * Install * Usage * Transforms * NOTE
case_transform2
Transforms string letter case to camel, snake, dash and underscore without activesupport dependencies.
Forked from Rails API CaseTransform gem
Why
We want a simple string method without polluting String class and lightweight.
If you want to use this into Rails application or any Ruby application with activesupport dependencies,
you might want to consider the original one instead.
Install
gem 'case_transform2'
or
gem install case_transform2
Usage
require 'case_transform2'
value = "hello_world"
CaseTransform.camel_lower(value) # => helloWorld
value = "hello_world"
CaseTransform.camel(value) # => HelloWorld
value = "hello_world"
CaseTransform.dash(value) # => hello-world
value = "helloWorld"
CaseTransform.underscore(value) # => hello_world
value
can be any of Array, Hash, Symbol, or String.
Any other object type will just be returned.
Transforms
Description | |
---|---|
camel | PascalCase |
camel_lower | camelCase |
dash | dash-case |
underscore | under_score |
NOTE
There is no CaseTransform.unaltered
method like the original gem has
License MIT