lib/ztk/ansi.rb
# Uncolor String
#
# Removes ANSI code sequences from a string.
#
# @param [String] string The string to operate on.
# @yieldreturn [String] The string to operate on.
# @return [String] The supplied string stripped of ANSI codes.
Uncolor String
Removes ANSI code sequences from a string.
Uncolor String Removes ANSI code sequences from a string .
def uncolor(string=nil, &block)
      if block_given?
        block.call.to_str.gsub(ANSI_REGEX, '')
      elsif string.respond_to?(:to_str)
        string.to_str.gsub(ANSI_REGEX, '')
      elsif respond_to?(:to_str)
        to_str.gsub(ANSI_REGEX, '')
      else
        ''
      end
    end
def uncolor ( string = nil , & block ) if block_given? block . call . to_str . gsub ( ANSI_REGEX , '' ) elsif string . respond_to? ( :to_str ) string . to_str . gsub ( ANSI_REGEX , '' ) elsif respond_to? ( :to_str ) to_str . gsub ( ANSI_REGEX , '' ) else '' end end
Uncolor String
Removes ANSI code sequences from a string.
Uncolor String Removes ANSI code sequences from a string .
The string to operate on.
The string to operate on .
String
The supplied string stripped of ANSI codes.
The supplied string stripped of ANSI codes .
String
string
<not_specific>
block
<not_specific>
<not_specific>
string The string to operate on.
string The string to operate on .