Module: RCheck::Colors::Mixin
- Included in:
- RCheck::Colors, ReportPrinters::Abstract
- Defined in:
- lib/rcheck/colors.rb
Instance Method Summary collapse
Instance Method Details
#cprint(status, *strings) ⇒ Object
36 37 38 |
# File 'lib/rcheck/colors.rb', line 36 def cprint(status, *strings) with_color(status) { print(*strings) } end |
#cputs(status, *args) ⇒ Object
40 41 42 |
# File 'lib/rcheck/colors.rb', line 40 def cputs(status, *args) with_color(status) { puts(*args) } end |
#with_color(status) ⇒ Object
26 27 28 29 30 31 32 33 34 |
# File 'lib/rcheck/colors.rb', line 26 def with_color(status) color = Conf[:colors][status] || raise("invalid status: #{status.inspect}") code = ESC[color] || raise("invalid color #{color.inspect}") # TODO: support color codes print code if STDOUT.tty? yield print ESC[:reset] if STDOUT.tty? end |