Files

Class Index [+]

Quicksearch

Term::ANSIColor

The ANSIColor module can be used for namespacing and mixed into your own classes.

Constants

COLORED_REGEXP

Regular expression that is used to scan for ANSI-sequences while uncoloring strings.

VERSION

Term::ANSIColor version

Public Class Methods

coloring=(val) click to toggle source

Turns the coloring on or off globally, so you can easily do this for example:

 Term::ANSIColor::coloring = STDOUT.isatty
    # File lib/term/ansicolor.rb, line 51
51:     def self.coloring=(val)
52:       @coloring = val
53:     end
coloring?() click to toggle source

Returns true, if the coloring function of this module is switched on, false otherwise.

    # File lib/term/ansicolor.rb, line 44
44:     def self.coloring?
45:       @coloring
46:     end

Public Instance Methods

attributes() click to toggle source

Returns an array of all Term::ANSIColor attributes as symbols.

    # File lib/term/ansicolor.rb, line 97
97:     def attributes
98:       ATTRIBUTE_NAMES
99:     end
uncolored(string = nil) click to toggle source

Returns an uncolored version of the string, that is all ANSI-sequences are stripped from the string.

    # File lib/term/ansicolor.rb, line 82
82:     def uncolored(string = nil) # :yields:
83:       if block_given?
84:         yield.gsub(COLORED_REGEXP, '')
85:       elsif string
86:         string.gsub(COLORED_REGEXP, '')
87:       elsif respond_to?(:to_str)
88:         to_str.gsub(COLORED_REGEXP, '')
89:       else
90:         ''
91:       end
92:     end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.