# File lib/airbrussh/console.rb, line 41 def truncate_to_console_width(string) string = (string || "").rstrip ellipsis = utf8_supported?(string) ? "…" : "..." width = console_width if strip_ascii_color(string).length > width width -= ellipsis.length string.chop! while strip_ascii_color(string).length > width string << "#{ellipsis}\e[0m" else string end end