1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
|
module Socksify
class Color
class Reset
def self::to_s
"\e[0m\e[37m"
end
end
class Red < Color
def num; 31; end
end
class Green < Color
def num; 32; end
end
class Yellow < Color
def num; 33; end
end
def self::to_s
new.to_s
end
def to_s
"\e[1m\e[#{num}m"
end
end
def self.debug=(enabled)
@@debug = enabled
end
def self.debug_debug(str)
debug(Color::Green, str)
end
def self.debug_notice(str)
debug(Color::Yellow, str)
end
def self.debug_error(str)
debug(Color::Red, str)
end
private
def self.debug(color, str)
if defined? @@debug
puts "#{color}#{now_s}#{Color::Reset} #{str}"
end
end
def self.now_s
Time.now.strftime('%H:%M:%S')
end
end
|