This seems like it would be ridiculously easy, but I can't find a method anywhere, to convert a sentence string/hyphenated string to camelcase.
Ex:
'this is a sentence' => 'thisIsASentence'
'my-name' => 'myName'
Seems overkill to use regex. What's the best way?
> s = 'this is a sentence'
=> "this is a sentence"
> s.gsub(/\s(.)/) {|e| $1.upcase}
=> "thisIsASentence"
You'd need to tweak that regexp to match on dashes in additions to spaces, but that's easy.
Pretty sure there's a regexp way to do it as well without needing to use the block form, but I didn't look it up.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With