Skip to content

Ruby Gem converts hashes in camelCase (or CamelCase) notation in to snake_notation and opposite way around

Notifications You must be signed in to change notification settings

mkarpicki/notation-converter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Build Status

NotationConverter

NotationConverter allows to convert between snake_notation and camelCase notation (both ways)
Published: https://rubygems.org/gems/notation_converter

Installing

gem install notation_converter

Static methods

NotationConverter.to_snake

Converts passed input to snake_notation

Examples

input = { 'myProp' => 'myValue'}
output = NotationConverter.to_snake input
# { 'my_prop' => 'myValue'}

input = { 'myProp' => 'myValue'}
output = NotationConverter.to_snake input, true
# { :my_prop => 'myValue'}

input = [{ 'myPropA' => 'myValue'}, { 'myPropB' => 'myValue'}]
output = NotationConverter.to_snake input, true
# [{ :my_prop_a => 'myValue'}, { :my_prop_b => 'myValue'}]

NotationConverter.to_lower_camel

Converts passed input to (lower) camelCase notation

Examples

input = { 'my_prop' => 'my_value'}
output = NotationConverter.to_lower_camel hash
# { 'myProp' => 'my_value'}

input = { 'myProp' => 'myValue'}
output = NotationConverter.to_lower_camel hash, true
# { :myProp => 'my_value'}

NotationConverter.to_upper_camel

Converts passed input to (Upper) CamelCase notation

Examples

input = { 'my_prop' => 'my_value'}
output = NotationConverter.to_upper_camel hash
# { 'MyProp' => 'my_value'}

input = { 'myProp' => 'myValue'}
output = NotationConverter.to_upper_camel hash, true
# { :MyProp => 'my_value'}

NotationConverter.to_camel

Converts passed input to camelCase notation (lower or upper based on passed type param)

Examples

input = { 'my_prop' => 'my_value'}
output = NotationConverter.to_camel hash
# { 'myProp' => 'my_value'}

input = { 'myProp' => 'myValue'}
output = NotationConverter.to_camel hash, :lower
# { 'myProp' => 'my_value'}

input = { 'myProp' => 'myValue'}
output = NotationConverter.to_camel hash, :upper
# { 'MyProp' => 'my_value'}

input = { 'myProp' => 'myValue'}
output = NotationConverter.to_camel hash, :lower, true
# { :myProp => 'my_value'}

input = { 'myProp' => 'myValue'}
output = NotationConverter.to_camel hash, :upper, true
# { :MyProp => 'my_value'}

About

Ruby Gem converts hashes in camelCase (or CamelCase) notation in to snake_notation and opposite way around

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages