Sha256: eda94e640d4e716679fe161da94f62fd48033a1f68f05e40e6d9b34351ca5f60
Contents?: true
Size: 1.32 KB
Versions: 5
Compression:
Stored size: 1.32 KB
Contents
# frozen_string_literal: true module Thinreports module BasicReport module Generator class PDF module ParseColor # @param [String] color # @return [String] def parse_color(color) color = color.downcase if color =~ /^#?[\da-f]{6}$/ color.delete('#') else find_color_from_name(color) 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' }.freeze def find_color_from_name(name) color = SUPPORTED_COLOR_NAMES[name] raise Thinreports::BasicReport::Errors::UnsupportedColorName, name unless color color end end end end end end
Version data entries
5 entries across 5 versions & 1 rubygems