Module: L43::SimpleColor
- Extended by:
- SimpleColor
- Included in:
- SimpleColor
- Defined in:
- lib/l43/simple_color.rb,
lib/l43/simple_color/version.rb
Constant Summary collapse
- Bold =
"\x1b[1m"- Dim =
"\x1b[2m"- Reset =
"\x1b[0m"- Underline =
"\x1b[4m"- Colors =
{ black: "\x1b[30m", blue: "\x1b[34m", cyan: "\x1b[36m", green: "\x1b[32m", magenta: "\x1b[35m", red: "\x1b[31m", white: "\x1b[37m", yellow: "\x1b[33m", bgblack: "\x1b[40m", bgblue: "\x1b[44m", bgcyan: "\x1b[46m", bggreen: "\x1b[42m", bgmagenta: "\x1b[45m", bgred: "\x1b[41m", bgwhite: "\x1b[47m", bgyellow: "\x1b[43m", b: Bold, bold: Bold, d: Dim, dim: Dim, r: Reset, reset: Reset, ul: Underline, underline: Underline, }
- VERSION =
'0.1.0'
Instance Method Summary collapse
Instance Method Details
#color(*chunks, reset: true) ⇒ Object
39 40 41 42 43 44 |
# File 'lib/l43/simple_color.rb', line 39 def color(*chunks, reset: true) reset = reset ? :reset : "" [*chunks.flatten, reset].map do |chunk| format_chunk(chunk) end.compact.join end |
#putc(*chunks, reset: true, device: $stderr) ⇒ Object
46 47 48 49 |
# File 'lib/l43/simple_color.rb', line 46 def putc(*chunks, reset: true, device: $stderr) colored = color(chunks, reset:) device.puts colored end |