Created
November 9, 2015 14:15
-
-
Save YusukeHosonuma/5afb91d8a60adf4ad209 to your computer and use it in GitHub Desktop.
Convert camelize string from underscore string.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def to_camelize(str) | |
s = str.split(/_/).map{|s| s.capitalize}.join('') | |
s[0] = s[0].downcase | |
s | |
end | |
underscore = 'apple_orange_banana' | |
camelize = to_camelize(underscore) | |
p camelize |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment