module Uspec::Terminal

Public Instance Methods

color(hue, text = nil) click to toggle source
# File lib/uspec/terminal.rb, line 14
def color hue, text = nil
  "#{esc "3#{colors[hue]};1"}#{text}#{normal unless text.nil?}"
end
colors() click to toggle source
# File lib/uspec/terminal.rb, line 5
def colors
  {
    red: 1,
    green: 2,
    yellow: 3,
    white: 7
  }
end
esc(seq) click to toggle source
# File lib/uspec/terminal.rb, line 18
def esc seq
  "\e[#{seq}m"
end
hspace() click to toggle source
# File lib/uspec/terminal.rb, line 26
def hspace
  '    '
end
method_missing(name, *args, &block) click to toggle source
Calls superclass method
# File lib/uspec/terminal.rb, line 38
def method_missing name, *args, &block
  if colors.keys.include? name then
    color name, *args
  else
    super
  end
end
newline() click to toggle source
# File lib/uspec/terminal.rb, line 34
def newline
  $/
end
normal(text=nil) click to toggle source
# File lib/uspec/terminal.rb, line 22
def normal text=nil
  "#{esc 0}#{text}"
end
vspace() click to toggle source
# File lib/uspec/terminal.rb, line 30
def vspace
  "#{newline}#{newline}"
end