Class: ColorCode
- Inherits:
-
Object
- Object
- ColorCode
- Defined in:
- lib/number_to_color.rb
Overview
Class to generate a hex color code based on a value and domain.
Instance Method Summary collapse
-
#hex_color ⇒ String
The public method to return the hex code.
-
#initialize(value:, domain: nil, middle_color: [255, 255, 255], end_color: [14, 165, 233], start_color: [248, 113, 113]) ⇒ ColorCode
constructor
A new instance of ColorCode.
Constructor Details
#initialize(value:, domain: nil, middle_color: [255, 255, 255], end_color: [14, 165, 233], start_color: [248, 113, 113]) ⇒ ColorCode
Returns a new instance of ColorCode.
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/number_to_color.rb', line 14 def initialize( value:, domain: nil, middle_color: [255, 255, 255], end_color: [14, 165, 233], start_color: [248, 113, 113] ) @value = value.to_f @domain = domain @middle_color = middle_color @start_color = start_color @end_color = end_color set_colors end |
Instance Method Details
#hex_color ⇒ String
The public method to return the hex code.
32 33 34 |
# File 'lib/number_to_color.rb', line 32 def hex_color rgb_to_hex(red: final_rgb[:r], green: final_rgb[:g], blue: final_rgb[:b]) end |