class Toys::Utils::Terminal

def apply_styles(str, *styles)

Returns:
  • (String) - The styled string

Parameters:
  • styles (Symbol, String, Array...) -- Styles to apply
  • str (String) -- String to style
def apply_styles(str, *styles)
  if styled
    prefix = escape_styles(*styles)
    suffix = prefix.empty? || str.end_with?(CLEAR_CODE) ? "" : CLEAR_CODE
    "#{prefix}#{str}#{suffix}"
  else
    Terminal.remove_style_escapes(str)
  end
end