lib/spoom/printer.rb in spoom-1.1.4 vs lib/spoom/printer.rb in spoom-1.1.5

- old
+ new

@@ -6,10 +6,12 @@ module Spoom class Printer extend T::Sig extend T::Helpers + include Colorize + abstract! sig { returns(T.any(IO, StringIO)) } attr_accessor :out @@ -40,15 +42,14 @@ end # Print `string` colored with `color` into `out` # # Does not use colors unless `@colors`. - sig { params(string: T.nilable(String), color: Symbol, colors: Symbol).void } - def print_colored(string, color, *colors) + sig { params(string: T.nilable(String), color: Color).void } + def print_colored(string, *color) return unless string - string = colorize(string, color) - colors.each { |c| string = colorize(string, c) } + string = T.unsafe(self).colorize(string, *color) @out.print(string) end # Print a new line into `out` sig { void } @@ -70,11 +71,12 @@ def printt print(" " * @indent_level) end # Colorize `string` with color if `@colors` - sig { params(string: String, color: Symbol).returns(String) } - def colorize(string, color) - @colors ? string.colorize(color) : string + sig { params(string: String, color: Spoom::Color).returns(String) } + def colorize(string, *color) + return string unless @colors + T.unsafe(self).set_color(string, *color) end end end