Class: Mutant::Color
- Inherits:
-
Object
- Object
- Mutant::Color
- Includes:
- Adamantium::Flat
- Defined in:
- lib/mutant/color.rb
Overview
Class to colorize strings
Constant Summary collapse
- NONE =
Class.new(self) do # Format null color # # @param [String] text # # @return [String] # returns the argument string # # @api private # def format(text) text end private # Initialize null color # # @return [undefined] # # @api private # def initialize(*) end end.new.freeze
- RED =
Color.new(31)
- GREEN =
Color.new(32)
- BLUE =
Color.new(34)
Instance Method Summary collapse
-
#format(text) ⇒ String
private
Format text with color.
-
#initialize(code) ⇒ undefined
constructor
private
Initialize color object.
Constructor Details
#initialize(code) ⇒ undefined
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Initialize color object
14 15 16 |
# File 'lib/mutant/color.rb', line 14 def initialize(code) @code = code end |
Instance Method Details
#format(text) ⇒ String
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Format text with color
26 27 28 |
# File 'lib/mutant/color.rb', line 26 def format(text) "\e[#{@code}m#{text}\e[0m" end |