Sha256: 53bd05e8d280e2527ec43e99c72cb828727a6d5563828b4726d979f781abf2f7
Contents?: true
Size: 1.15 KB
Versions: 1
Compression:
Stored size: 1.15 KB
Contents
# coding: utf-8 module ThinReports module Generator # @private 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) unless color = SUPPORTED_COLOR_NAMES[name] raise ThinReports::Errors::UnsupportedColorName, name end color end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
thinreports-0.6.0.pre3 | lib/thinreports/generator/pdf/document/parse_color.rb |