Skip to content

Instantly share code, notes, and snippets.

@basicxman
Created June 3, 2011 16:21
Show Gist options
  • Select an option

  • Save basicxman/1006623 to your computer and use it in GitHub Desktop.

Select an option

Save basicxman/1006623 to your computer and use it in GitHub Desktop.
# Process a color type, returns a function symbol.
#------------------------------------------------------------------------------
def color_func(c)
temp = "fg"
if c.is_a? Array
temp += AwesomePrint::Helpers::rgb(*c)
elsif c.is_a? Fixnum
temp += c >= 0 and c <= 255 ? c.to_s : "255"
elsif c.is_a? String
if (c.length == 7 or c.length == 6) and not (c =~ /#?[0-9A-Fa-f]{6}/).nil?
temp += AwesomePrint::Helpers::hex(c)
else
temp = c
end
else
temp += "255"
end
temp.to_sym
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment