Class: Kojak::Printer::Colorized
- Inherits:
-
Synchronized
- Object
- Kojak::Printer
- Basic
- Synchronized
- Kojak::Printer::Colorized
- Defined in:
- lib/kojak/printer/colorized.rb
Overview
Internal: Special version of thread-safe printer that additionally colorizes the output with one preconfigured color.
Direct Known Subclasses
Instance Attribute Summary collapse
-
#color ⇒ Object
Public: The String or Symbol with name of the assigned color.
Instance Method Summary collapse
-
#initialize(out, color = :white) ⇒ Colorized
constructor
Public: Constructor.
- #write(s, *args) ⇒ Object
Methods inherited from Kojak::Printer
Constructor Details
#initialize(out, color = :white) ⇒ Colorized
Public: Constructor. Configures printer to write to given output in specified color.
out - The Stream to write data to. color - The String or Symbol with name of the color to use.
Returns nothing.
17 18 19 20 21 22 |
# File 'lib/kojak/printer/colorized.rb', line 17 def initialize(out, color = :white) super(out) @color = color @rainbow = Rainbow.new end |
Instance Attribute Details
#color ⇒ Object
Public: The String or Symbol with name of the assigned color.
8 9 10 |
# File 'lib/kojak/printer/colorized.rb', line 8 def color @color end |
Instance Method Details
#write(s, *args) ⇒ Object
24 25 26 |
# File 'lib/kojak/printer/colorized.rb', line 24 def write(s, *args) super(@rainbow.wrap(s.to_s).color(color), *args) end |