Module: Sai::Decorator::HexColors Abstract Private
- Included in:
- Sai::Decorator
- Defined in:
- lib/sai/decorator/hex_colors.rb
Overview
This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.
This module is abstract.
This module is meant to be included in the Sai::Decorator class to provide hexadecimal color methods
Hexadecimal color methods for the Sai::Decorator class
Instance Method Summary collapse
-
#hex(code) ⇒ Decorator
Apply a hexadecimal color to the foreground.
-
#on_hex(code) ⇒ Decorator
Apply a hexadecimal color to the background.
Instance Method Details
#hex(code) ⇒ Decorator
Apply a hexadecimal color to the foreground
28 29 30 31 32 |
# File 'lib/sai/decorator/hex_colors.rb', line 28 def hex(code) raise ArgumentError, "Invalid hex color code: #{code}" unless /^#?([A-Fa-f0-9]{6})$/.match?(code) dup.tap { |duped| duped.instance_variable_set(:@foreground, code) } #: Decorator end |
#on_hex(code) ⇒ Decorator
Apply a hexadecimal color to the background
49 50 51 52 53 |
# File 'lib/sai/decorator/hex_colors.rb', line 49 def on_hex(code) raise ArgumentError, "Invalid hex color code: #{code}" unless /^#?([A-Fa-f0-9]{6})$/.match?(code) dup.tap { |duped| duped.instance_variable_set(:@background, code) } #: Decorator end |