Module: Colir::HSLRGB::RGB
- Defined in:
- lib/colir/hslrgb.rb
Overview
Provides helper methods for the RGB colours.
Constant Summary collapse
- RGB_RANGE =
The possible values of an RGB colour.
0x000000..0xffffff
- RGB_BYTE_RANGE =
The possible values of an RGB byte.
0x00..0xff
Class Method Summary collapse
-
.int_bytes(hex) ⇒ Array<Integer>
Converts
hex
number to the RGB array. -
.valid_rgb?(rgb) ⇒ Boolean
Performs a validation check for the
rgb
.
Class Method Details
.int_bytes(hex) ⇒ Array<Integer>
Converts hex
number to the RGB array.
42 43 44 |
# File 'lib/colir/hslrgb.rb', line 42 def self.int_bytes(hex) hex.to_s(16).rjust(6, '0').scan(/../).map { |b| b.to_i(16) } end |
.valid_rgb?(rgb) ⇒ Boolean
Performs a validation check for the rgb
.
31 32 33 |
# File 'lib/colir/hslrgb.rb', line 31 def self.valid_rgb?(rgb) rgb.all? { |b| valid_byte?(b) } && (rgb.length == 3) end |