Sha256: 6d7f3828016b5ecea04ef091fef3fa1a0bfeabecfe62c4608b6240cf1858b85e
Contents?: true
Size: 1.1 KB
Versions: 3
Compression:
Stored size: 1.1 KB
Contents
# coding: utf-8 module Thinreports module Generator module PDF::ParseColor # @param [String] color # @return [String] def parse_color(color) color = color.downcase unless color =~ /^#?[\da-f]{6}$/ find_color_from_name(color) else color.delete('#') end end private # Supported only SAFE COLORS. SUPPORTED_COLOR_NAMES = { 'red' => 'ff0000', 'yellow' => 'fff000', 'lime' => '00ff00', 'aqua' => '00ffff', 'blue' => '0000ff', 'fuchsia' => 'ff00ff', 'maroon' => '800000', 'olive' => '808000', 'green' => '008800', 'teal' => '008080', 'navy' => '000080', 'purple' => '800080', 'black' => '000000', 'gray' => '808080', 'silver' => 'c0c0c0', 'white' => 'ffffff' } def find_color_from_name(name) color = SUPPORTED_COLOR_NAMES[name] raise Thinreports::Errors::UnsupportedColorName, name unless color color end end end end
Version data entries
3 entries across 3 versions & 1 rubygems