Module: Corefines::String::Decolor

Defined in:
lib/corefines/string.rb

Instance Method Summary collapse

Instance Method Details

#decolorString

Returns a copy of this string without ANSI escape codes (e.g. colors).

See Also:


179
180
181
182
183
184
185
186
187
# File 'lib/corefines/string.rb', line 179

module Decolor
  refine ::String do
    def decolor
      scan(ESCAPE_SEQUENCE).reduce('') do |str, match|
        str << (match[3] || match[4])
      end
    end
  end
end