module ChunkyPNG::Color
def parse(source)
-
(Integer)
- The color value, with the opacity applied if one was given.
Parameters:
-
The
(Integer, String
) -- color value.
def parse(source) return source if source.kind_of?(Integer) case source.to_s when /^\d+$/; source.to_s.to_i when ChunkyPNG::Color::HEX_COLOR_REGEXP; ChunkyPNG::Color.from_hex(source.to_s) when ChunkyPNG::Color::HTML_COLOR_REGEXP; ChunkyPNG::Color.html_color(source.to_s) else raise ArgumentError, "Don't know how to create a color from #{source.inspect}!" end end