Module: Term::ANSIColor
- Defined in:
- lib/carat/ansicolor.rb
Constant Summary collapse
- ColoredRegexp =
/\e\[([34][0-7]|[0-9])m/- @@attributes =
[ [ :clear , 0 ], [ :reset , 0 ], # synonym for :clear [ :bold , 1 ], [ :dark , 2 ], [ :italic , 3 ], # not widely implemented [ :underline , 4 ], [ :underscore , 4 ], # synonym for :underline [ :blink , 5 ], [ :rapid_blink , 6 ], # not widely implemented [ :negative , 7 ], # no reverse because of String#reverse [ :concealed , 8 ], [ :strikethrough, 9 ], # not widely implemented [ :black , 30 ], [ :red , 31 ], [ :green , 32 ], [ :yellow , 33 ], [ :blue , 34 ], [ :magenta , 35 ], [ :cyan , 36 ], [ :white , 37 ], [ :on_black , 40 ], [ :on_red , 41 ], [ :on_green , 42 ], [ :on_yellow , 43 ], [ :on_blue , 44 ], [ :on_magenta , 45 ], [ :on_cyan , 46 ], [ :on_white , 47 ], ]
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.attributes ⇒ Object
115 116 117 |
# File 'lib/carat/ansicolor.rb', line 115 def attributes @@attributes.map { |c| c[0] } end |
Instance Method Details
#uncolored(string = nil) ⇒ Object
101 102 103 104 105 106 107 108 109 110 111 |
# File 'lib/carat/ansicolor.rb', line 101 def uncolored(string = nil) if block_given? yield.gsub(ColoredRegexp, '') elsif string string.gsub(ColoredRegexp, '') elsif respond_to?(:to_str) gsub(ColoredRegexp, '') else '' end end |