Sha256: 815a46df3d8bcc15f3ba48ac5b4b5dc4ed3e4266141a173174f680261e761f4b
Contents?: true
Size: 593 Bytes
Versions: 2
Compression:
Stored size: 593 Bytes
Contents
module RGBUtils class HexToRGBConverter < Converter def initialize(color) @color = color end def convert return color if color.is_a?(RGB) @rgb ||= begin red, green, blue = capture_colors RGB.new(red: red, green: green, blue: blue) end end private attr_accessor :color def capture_colors @capture_colors ||= begin WebSafeToHexConverter .convert(color) .match(/(\w{2})(\w{2})(\w{2})/) .captures .map { |color_node| color_node.to_i(16) } end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
rgb_utils-0.1.2 | lib/rgb_utils/converters/hex_to_rgb_converter.rb |
rgb_utils-0.1.1 | lib/rgb_utils/converters/hex_to_rgb_converter.rb |