Class: PaintbrushSupport::HexColorCode
- Inherits:
-
Object
- Object
- PaintbrushSupport::HexColorCode
- Defined in:
- lib/paintbrush_support/hex_color_code.rb
Overview
Translates a string in format ‘hex_ff00ff` or `hex_f0f` into an RGB escape code sequence. Allows calling e.g.:
paintbrush { hex_ff0ff ‘hello in magenta’ }
Instance Method Summary collapse
- #escape_sequence ⇒ Object
-
#initialize(hex_code:) ⇒ HexColorCode
constructor
A new instance of HexColorCode.
Constructor Details
#initialize(hex_code:) ⇒ HexColorCode
Returns a new instance of HexColorCode.
10 11 12 |
# File 'lib/paintbrush_support/hex_color_code.rb', line 10 def initialize(hex_code:) @hex_code = hex_code end |
Instance Method Details
#escape_sequence ⇒ Object
14 15 16 |
# File 'lib/paintbrush_support/hex_color_code.rb', line 14 def escape_sequence (%w[38 2] + encoded_pairs).join(';') end |