Billy Logan Billy Logan - 1 year ago 84
Ruby Question

How to convert string to UpperCamelCase in Ruby?

I want to turn string into CamelCase fashion In Ruby. The question also applies to words with underscores.

For example:

"human" => "Human"
"little_human" => "LittleHuman"

How can I do this?

Answer Source

In rails there is a camelize method. In ruby you can write the method on your own. Something like

def camelize(s)
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download