Menu

Toshimaru's Blog

Convert lowercase to uppercase in Ruby

lowercase → uppercase

upcase

Convert all letters to uppercase.

'hello'.upcase
#=> "HELLO"

capitalize

Convert first letter to uppercase.

'hello'.capitalize
#=> "Hello"

camelize

Convert snake case to camel case.

This method is provided by ActiveSupport.

'snake_case'.camelize
#=> "SnakeCase"

lower camelize

Convert snake case to lower camel case.

This method is provided by ActiveSupport.

'snake_case'.camelize(:lower)
#=> "snakeCase"

uppercase → lowercase

downcase

Convert uppercase to lowercase.

'ABC'.downcase
#=> "abc"

underscore

Conver camel case to snake case.

This method is provided by ActiveSupport.

'HelloWorld'.underscore
#=> "hello_world"

swapcase

Swap letters.

'AbC'.swapcase
#=> "aBc"
Load more