Используйте объект
*/
В Вашей документации, которую он разоблачит как "* /"
Colorize - моя любимая жемчужина! : -)
Проверьте это:
https://github.com/fazibear/colorize
Установка:
gem install colorize
Использование:
require 'colorize'
puts "I am now red".red
puts "I am now blue".blue
puts "Testing".yellow
You can use ANSI escape sequences to do this on the console. I know this works on Linux and OSX, I'm not sure if the Windows console (cmd) supports ANSI.
I did it in Java, but the ideas are the same.
//foreground color
public static final String BLACK_TEXT() { return "\033[30m";}
public static final String RED_TEXT() { return "\033[31m";}
public static final String GREEN_TEXT() { return "\033[32m";}
public static final String BROWN_TEXT() { return "\033[33m";}
public static final String BLUE_TEXT() { return "\033[34m";}
public static final String MAGENTA_TEXT() { return "\033[35m";}
public static final String CYAN_TEXT() { return "\033[36m";}
public static final String GRAY_TEXT() { return "\033[37m";}
//background color
public static final String BLACK_BACK() { return "\033[40m";}
public static final String RED_BACK() { return "\033[41m";}
public static final String GREEN_BACK() { return "\033[42m";}
public static final String BROWN_BACK() { return "\033[43m";}
public static final String BLUE_BACK() { return "\033[44m";}
public static final String MAGENTA_BACK() { return "\033[45m";}
public static final String CYAN_BACK() { return "\033[46m";}
public static final String WHITE_BACK() { return "\033[47m";}
//ANSI control chars
public static final String RESET_COLORS() { return "\033[0m";}
public static final String BOLD_ON() { return "\033[1m";}
public static final String BLINK_ON() { return "\033[5m";}
public static final String REVERSE_ON() { return "\033[7m";}
public static final String BOLD_OFF() { return "\033[22m";}
public static final String BLINK_OFF() { return "\033[25m";}
public static final String REVERSE_OFF() { return "\033[27m";}
Я нашел несколько:
http: // github .com / ssoroka / ansi / tree / master
Примеры:
puts ANSI.color(:red) { "hello there" }
puts ANSI.color(:green) + "Everything is green now" + ANSI.no_color
http://flori.github.com/term-ansicolor/
Примеры:
print red, bold, "red bold", reset, "\n"
print red(bold("red bold")), "\n"
print red { bold { "red bold" } }, "\n"
http://github.com/sickill/ rainbow
Пример:
puts "this is red".foreground(:red) + " and " + "this on yellow bg".background(:yellow) + " and " + "even bright underlined!".underline.bright
Если вы работаете в Windows, вам может потребоваться выполнить «gem install win32console», чтобы включить поддержку цветов.
Также есть статья Вывод Ruby-скрипта консоли раскрашивания полезно, если вам нужно создать свой собственный драгоценный камень. В нем объясняется, как добавить к строкам раскраску ANSI. Вы можете использовать эти знания, чтобы обернуть их в некоторый класс, расширяющий строку или что-то в этом роде.
puts ANSI.color(:red) { "hello there" }
puts ANSI.color(:green) + "Everything is green now" + ANSI.no_color
http://flori.github.com/term-ansicolor/
Примеры:
print red, bold, "red bold", reset, "\n"
print red(bold("red bold")), "\n"
print red { bold { "red bold" } }, "\n"
http://github.com/sickill/rainbow
Пример:
puts "this is red".foreground(:red) + " and " + "this on yellow bg".background(:yellow) + " and " + "even bright underlined!".underline.bright
Если вы используете Windows, вы может потребоваться выполнить «gem install win32console», чтобы включить поддержку цветов.
Также статья Раскрашивание вывода Ruby-скрипта консоли полезна, если вам нужно создать свой собственный гем. В нем объясняется, как добавить к строкам раскраску ANSI. Вы можете использовать эти знания, чтобы обернуть их в некоторый класс, расширяющий строку или что-то в этом роде.
puts ANSI.color(:red) { "hello there" }
puts ANSI.color(:green) + "Everything is green now" + ANSI.no_color
http://flori.github.com/term-ansicolor/
Примеры:
print red, bold, "red bold", reset, "\n"
print red(bold("red bold")), "\n"
print red { bold { "red bold" } }, "\n"
http://github.com/sickill/rainbow
Пример:
puts "this is red".foreground(:red) + " and " + "this on yellow bg".background(:yellow) + " and " + "even bright underlined!".underline.bright
Если вы используете Windows, вы может потребоваться выполнить «gem install win32console», чтобы включить поддержку цветов.
Также статья Раскрашивание вывода Ruby-скрипта консоли полезна, если вам нужно создать свой собственный гем. В нем объясняется, как добавить к строкам раскраску ANSI. Вы можете использовать эти знания, чтобы обернуть их в некоторый класс, расширяющий строку или что-то в этом роде.
В нем объясняется, как добавить к строкам раскраску ANSI. Вы можете использовать эти знания, чтобы обернуть их в некоторый класс, расширяющий строку или что-то в этом роде. В нем объясняется, как добавить к строкам раскраску ANSI. Вы можете использовать эти знания, чтобы обернуть их в некоторый класс, расширяющий строку или что-то в этом роде.