class Object

Constants

BG
BOLD
COLORS

functions to apply colors to terminal output

CSV_MIME
FG
NEUTRAL
ODS_MIME
ODS_Magic

Transforms a file into a Roo spreadsheet instance.

RD

/***************************************************************************

*   ©2011-2014, Michael Uplawski                                          * 
*   <michael.uplawski@uplawski.eu>                                        *
*                                                                         *
*   This program is free software; you can redistribute it and/or modify  *
*   it under the terms of the GNU General Public License as published by  *
*   the Free Software Foundation; either version 3 of the License, or     *
*   (at your option) any later version.                                   *
*                                                                         * 
*   This program is distributed in the hope that it will be useful,       *
*   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
*   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
*   GNU General Public License for more details.                          *
*                                                                         *
*   You should have received a copy of the GNU General Public License     *
*   along with this program; if not, write to the                         *
*   Free Software Foundation, Inc.,                                       *
*   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
***************************************************************************/
REGULAR
STYLES
SWAP
UNDERLINE
XLSX_MIME
XLSX_Magic
XLS_MIME
XLS_Magic

Public Instance Methods

black_on_white(text) click to toggle source
# File lib/color_output.rb, line 38
def black_on_white(text); colorize(colorize(text, "\033[30m"), "\033[47m");end
blue(text) click to toggle source
# File lib/color_output.rb, line 35
def blue(text); colorize(text, "\033[34m"); end
bold(text) click to toggle source
# File lib/color_output.rb, line 41
def bold(text); style(text, "\033[01m");end
busy_indicator(width) click to toggle source
# File lib/busy_indicator/busy_function_test.rb, line 35
def busy_indicator(width)
  tobj = Thread.new() do
    loop do 
      %w"OOO ooo ___ ooo".each do |s|
        print "%+#{width}s" %s
        sleep 0.1
        print ("\b" * width)
      end
    end
  end
end
clean_busy_indicator(thr, width, comment) click to toggle source
# File lib/busy_indicator/busy_function_test.rb, line 28
def clean_busy_indicator(thr, width, comment)
  thr.terminate
  thr.join
  print ("\b" * width)
  print ("%+#{width}s\n" %comment)
end
colored_output(output_text, fg_color = :default, bg_color = :default, style = :regular , mode = :neutral ) click to toggle source
# File lib/color_output.rb, line 26
def colored_output(output_text, fg_color = :default, bg_color = :default, style = :regular , mode = :neutral )
  "\033[%i;%i;%i%i;%i%im%s\033[0m" %[STYLES[mode.to_sym], STYLES[style.to_sym], FG, COLORS[fg_color.to_sym], BG, COLORS[bg_color.to_sym], output_text]
end
colorize(text, color_code) click to toggle source
# File lib/color_output.rb, line 18
def colorize(text, color_code)
    "#{color_code}#{text}\033[0m"
end
cyan(text) click to toggle source
# File lib/color_output.rb, line 34
def cyan(text); colorize(text, "\033[36m"); end
debout(str) click to toggle source
# File lib/user_input.rb, line 44
def debout(str)
  if $DEBUG == :DEBUG
    puts str
    if(wait_for_user().chr == 'q')
      exit true
    end
  end
end
green(text) click to toggle source
# File lib/color_output.rb, line 31
def green(text); colorize(text, "\033[32m"); end
purple(text) click to toggle source
# File lib/color_output.rb, line 33
def purple(text); colorize(text, "\033[35m"); end
red(text) click to toggle source
# File lib/color_output.rb, line 30
def red(text); colorize(text, "\033[31m"); end
style(text, style_code) click to toggle source
# File lib/color_output.rb, line 22
def style(text, style_code)
  "#{style_code}#{text}\033[0m"
end
underline(text) click to toggle source
# File lib/color_output.rb, line 42
def underline(text); style(text, "\033[04m");end
wait_for_user() click to toggle source

unblocking read from STDIN

# File lib/user_input.rb, line 29
def wait_for_user()
        char = nil
  # char = STDIN.raw(&:getc)
        STDIN.raw do 
                STDIN.noecho do
                        until (STDIN.ready?)
                                sleep(0.1)
                        end

                        char = (STDIN.read_nonblock(1).ord rescue nil)
                end
        end
  return char
end
white(text) click to toggle source
# File lib/color_output.rb, line 36
def white(text); colorize(text, "\033[37m"); end
white_on_black(text) click to toggle source
# File lib/color_output.rb, line 39
def white_on_black(text); colorize(colorize(text, "\033[37m"), "\033[40m");end
yellow(text) click to toggle source
# File lib/color_output.rb, line 32
def yellow(text); colorize(text, "\033[33m"); end