更好的ruby终端着色库

有很多着色库:彩色,term-ansicolor.
但有没有可以做到这一点:

puts "#{'hello'.red} world!".bold

和世界!应该是大胆的.

为了说清楚,我想得到这个:

"\e[1m\e[31mhello\e[0m\e[1m world!\e[0m"

甚至更好(更短):

"\e[1;31mhello\e[0;1m world!\e[0m"

而不是这个:

"\e[1m\e[31mhello\e[0m world!\e[0m"

解决方法

由于没有,我写了自己的,二十一点和妓女聪明一个smart_colored

gem install smart_colored

并运行

require 'smart_colored/extend'
# without extend you'll need to use 'string'.colored.red

puts "#{'hello'.red} world!".bold

相关文章

validates:conclusion,:presence=>true,:inclusion=>{...
一、redis集群搭建redis3.0以前,提供了Sentinel工具来监控各...
分享一下我老师大神的人工智能教程。零基础!通俗易懂!风趣...
上一篇博文 ruby传参之引用类型 里边定义了一个方法名 mo...
一编程与编程语言 什么是编程语言? 能够被计算机所识别的表...
Ruby类和对象Ruby是一种完美的面向对象编程语言。面向对象编...