Module: Rscons::Ansi
- Defined in:
- lib/rscons/ansi.rb
Overview
Module to contain logic to write ANSI color escape codes.
Class Method Summary collapse
-
.write(io, *message) ⇒ void
Write a message to an IO with ANSI escape codes.
Class Method Details
.write(io, *message) ⇒ void
This method returns an undefined value.
Write a message to an IO with ANSI escape codes.
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/rscons/ansi.rb', line 14 def write(io, *) do_color = Rscons.do_ansi_color if do_color.nil? do_color = do_ansi?(io) end out = "" .each do |m| if m.is_a?(String) out += m elsif do_color case m when :red out += "\e[0;31m" when :cyan out += "\e[0;36m" when :reset out += "\e[0m" end end end io.write(out) end |