File: util.rb

package info (click to toggle)
ruby-terminal-table 3.0.2-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 224 kB
  • sloc: ruby: 874; makefile: 3
file content (13 lines) | stat: -rw-r--r-- 348 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
module Terminal
  class Table
    module Util
      # removes all ANSI escape sequences (e.g. color)
      def ansi_escape(line)
        line.to_s.gsub(/\x1b(\[|\(|\))[;?0-9]*[0-9A-Za-z]/, '').
          gsub(/\x1b(\[|\(|\))[;?0-9]*[0-9A-Za-z]/, '').
          gsub(/(\x03|\x1a)/, '')
      end
      module_function :ansi_escape
    end
  end
end