class Tty
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.
Public Class Methods
# File lib/lace/utils.rb, line 26 def blue; bold 34; end
# File lib/lace/utils.rb, line 31 def em; underline 39; end
# File lib/lace/utils.rb, line 33 def gray; bold 30 end
# File lib/lace/utils.rb, line 32 def green; color 92 end
# File lib/lace/utils.rb, line 28 def red; underline 31; end
# File lib/lace/utils.rb, line 30 def reset; escape 0; end
# File lib/lace/utils.rb, line 39 def truncate(str) str.to_s[0, width - 4] end
# File lib/lace/utils.rb, line 27 def white; bold 39; end
# File lib/lace/utils.rb, line 35 def width `/usr/bin/tput cols`.strip.to_i end
# File lib/lace/utils.rb, line 29 def yellow; underline 33 ; end
Private Class Methods
# File lib/lace/utils.rb, line 48 def bold n escape "1;#{n}" end
# File lib/lace/utils.rb, line 45 def color n escape "0;#{n}" end
# File lib/lace/utils.rb, line 54 def escape n "\033[#{n}m" if $stdout.tty? end
# File lib/lace/utils.rb, line 51 def underline n escape "4;#{n}" end