module Simple::Ansi

Constants

ANSI_MATCH
COLORS
VERSION

Public Instance Methods

clear() click to toggle source
# File lib/simple/ansi.rb, line 29
def clear
  $stdout.print "\x1b[H\x1b[2J"
end
clear_line(str = "") click to toggle source
# File lib/simple/ansi.rb, line 55
def clear_line(str = "")
  "\x1b[2K\r#{str}\r"
end
has?(str) click to toggle source
# File lib/simple/ansi.rb, line 35
def has?(str)
  str.match(ANSI_MATCH).is_a?(MatchData)
end
jump(str, num) click to toggle source

Jump the cursor, moving it up and then back down to it’s spot, allowing you to do fancy things like multiple output (downloads) the way that Docker does them in an async way without breaking term.

# File lib/simple/ansi.rb, line 43
def jump(str, num)
  "\x1b[#{num}A#{clear_line(str)}\x1b[#{num}B"
end
reset(str = "") click to toggle source
# File lib/simple/ansi.rb, line 49
def reset(str = "")
  "\x1b[0m#{str}"
end
strip(str) click to toggle source
# File lib/simple/ansi.rb, line 23
def strip(str)
  str.gsub ANSI_MATCH, ""
end