Class: Tty

Inherits:
Object
  • Object
show all
Defined in:
lib/lace/utils.rb

Overview

Copyright 2009-2014 Max Howell and other contributors.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.

  2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE AUTHOR “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Class Method Summary collapse

Class Method Details

.blueObject



26
# File 'lib/lace/utils.rb', line 26

def blue; bold 34; end

.emObject



31
# File 'lib/lace/utils.rb', line 31

def em; underline 39; end

.grayObject



33
# File 'lib/lace/utils.rb', line 33

def gray; bold 30 end

.greenObject



32
# File 'lib/lace/utils.rb', line 32

def green; color 92 end

.redObject



28
# File 'lib/lace/utils.rb', line 28

def red; underline 31; end

.resetObject



30
# File 'lib/lace/utils.rb', line 30

def reset; escape 0; end

.truncate(str) ⇒ Object



39
40
41
# File 'lib/lace/utils.rb', line 39

def truncate(str)
  str.to_s[0, width - 4]
end

.whiteObject



27
# File 'lib/lace/utils.rb', line 27

def white; bold 39; end

.widthObject



35
36
37
# File 'lib/lace/utils.rb', line 35

def width
  `/usr/bin/tput cols`.strip.to_i
end

.yellowObject



29
# File 'lib/lace/utils.rb', line 29

def yellow; underline 33 ; end