Created
August 24, 2015 18:29
-
-
Save guilleiguaran/3c6af5b808e6f9113505 to your computer and use it in GitHub Desktop.
This file contains 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 camelize(""), | |
do: "" | |
def camelize(<<?_, t :: binary>>), | |
do: camelize(t) | |
def camelize(<<h, t :: binary>>), | |
do: <<to_upper_char(h)>> <> do_camelize(t) | |
defp do_camelize(<<?_, ?_, t :: binary>>), | |
do: do_camelize(<< ?_, t :: binary >>) | |
defp do_camelize(<<?_, h, t :: binary>>) when h in ?a..?z, | |
do: <<to_upper_char(h)>> <> do_camelize(t) | |
defp do_camelize(<<?_>>), | |
do: <<>> | |
defp do_camelize(<<?/, t :: binary>>), | |
do: <<?.>> <> camelize(t) | |
defp do_camelize(<<h, t :: binary>>), | |
do: <<h>> <> do_camelize(t) | |
defp do_camelize(<<>>), | |
do: <<>> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment