module Thinreports::Generator::PDF::ParseColor

Constants

SUPPORTED_COLOR_NAMES

Supported only SAFE COLORS.

Public Instance Methods

parse_color(color) click to toggle source

@param [String] color @return [String]

# File lib/thinreports/generator/pdf/document/parse_color.rb, line 9
def parse_color(color)
  color = color.downcase

  if color =~ /^#?[\da-f]{6}$/
    color.delete('#')
  else
    find_color_from_name(color)
  end
end

Private Instance Methods

find_color_from_name(name) click to toggle source
# File lib/thinreports/generator/pdf/document/parse_color.rb, line 41
def find_color_from_name(name)
  color = SUPPORTED_COLOR_NAMES[name]
  raise Thinreports::Errors::UnsupportedColorName, name unless color
  color
end