Module: Sai::Decorator::RGBColors Abstract Private
- Included in:
- Sai::Decorator
- Defined in:
- lib/sai/decorator/rgb_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 RGB color methods
RGB color methods for the Sai::Decorator class
Instance Method Summary collapse
-
#on_rgb(red, green, blue) ⇒ Decorator
Apply an RGB color to the background.
-
#rgb(red, green, blue) ⇒ Decorator
Apply an RGB color to the foreground.
Instance Method Details
#on_rgb(red, green, blue) ⇒ Decorator
Apply an RGB color to the background
30 31 32 33 34 35 36 |
# File 'lib/sai/decorator/rgb_colors.rb', line 30 def on_rgb(red, green, blue) [red, green, blue].each do |value| raise ArgumentError, "Invalid RGB value: #{red}, #{green}, #{blue}" unless value >= 0 && value <= 255 end dup.tap { |duped| duped.instance_variable_set(:@background, [red, green, blue]) } #: Decorator end |
#rgb(red, green, blue) ⇒ Decorator
Apply an RGB color to the foreground
55 56 57 58 59 60 61 |
# File 'lib/sai/decorator/rgb_colors.rb', line 55 def rgb(red, green, blue) [red, green, blue].each do |value| raise ArgumentError, "Invalid RGB value: #{red}, #{green}, #{blue}" unless value >= 0 && value <= 255 end dup.tap { |duped| duped.instance_variable_set(:@foreground, [red, green, blue]) } #: Decorator end |