Skip to content

Instantly share code, notes, and snippets.

@bplexico
Created August 15, 2013 21:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bplexico/6245199 to your computer and use it in GitHub Desktop.
Save bplexico/6245199 to your computer and use it in GitHub Desktop.
method before refactor
def self.get_hex(color)
case
when color.length == 1
generated_color = color * 6
when color.length == 2
generated_color = color * 3
when color.length == 3
generated_color = (color[0] * 2) + (color[1] * 2) + (color[2] * 2)
when color.length < 6 && color.length > 3
generated_color = color + ("0" * (6 - color.length))
when color.length > 6
generated_color = color[0..5]
else
generated_color = color
end
return "##{generated_color}"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment