Sha256: 343b8f3a64d557f6347798f8b2b0585f93ecd993b61d65db1cac3ae7701b6b17
Contents?: true
Size: 905 Bytes
Versions: 2
Compression:
Stored size: 905 Bytes
Contents
# frozen_string_literal: true module OoxmlParser # Helper methods for color module ColorHelper # Parse string in hex # @param [String] hex_string with or without alpha-channel def parse_hex_string(hex_string) return self if %w[auto null].include?(hex_string) char_array = hex_string.split(//) case char_array.length when 3 @red = char_array[0].hex @green = char_array[1].hex @blue = char_array[2].hex when 6 @red = (char_array[0] + char_array[1]).hex @green = (char_array[2] + char_array[3]).hex @blue = (char_array[4] + char_array[5]).hex when 8 @alpha_channel = (char_array[0] + char_array[1]).hex @red = (char_array[2] + char_array[3]).hex @green = (char_array[4] + char_array[5]).hex @blue = (char_array[6] + char_array[7]).hex end self end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
ooxml_parser-0.8.1 | lib/ooxml_parser/common_parser/common_data/color/color_helper.rb |
ooxml_parser-0.8.0 | lib/ooxml_parser/common_parser/common_data/color/color_helper.rb |