Module: SpreadsheetBuilder::Palette
- Defined in:
- lib/spreadsheet_builder/palette.rb
Class Method Summary collapse
Class Method Details
._color_from_input(input) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/spreadsheet_builder/palette.rb', line 19 def self._color_from_input(input) input = input.to_s if input =~ /^rgb/i _, r, g, b = input.match(/^rgba*\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)[^\)]*/) r, g, b = [r, g, b].map(&:to_i) input = "##{Spreadsheet::Excel::Rgb.new(r, g, b).as_hex.ljust(6, "0")}" end # Assume a color is always found color = PALETTE.nearest_value(input).name.to_sym color end |