The ANSIColor module can be used for namespacing and mixed into your own classes.
Regular expression that is used to scan for ANSI-sequences while uncoloring strings.
Turns the coloring on or off globally, so you can easily do this for example:
Cucumber::Term::ANSIColor::coloring = STDOUT.isatty
# File lib/cucumber/term/ansicolor.rb, line 50 def self.coloring=(val) @coloring = val end
Returns true, if the coloring function of this module is switched on, false otherwise.
# File lib/cucumber/term/ansicolor.rb, line 43 def self.coloring? @coloring end
# File lib/cucumber/term/ansicolor.rb, line 80 def self.included(klass) if version_is_greater_than_18? and klass == String ATTRIBUTES.delete(:clear) ATTRIBUTE_NAMES.delete(:clear) end end
Returns an array of all Cucumber::Term::ANSIColor attributes as symbols.
# File lib/cucumber/term/ansicolor.rb, line 104 def attributes ATTRIBUTE_NAMES end
Returns an uncolored version of the string, that is all ANSI-sequences are stripped from the string.
# File lib/cucumber/term/ansicolor.rb, line 89 def uncolored(string = nil) # :yields: if block_given? yield.gsub(COLORED_REGEXP, '') elsif string string.gsub(COLORED_REGEXP, '') elsif respond_to?(:to_str) to_str.gsub(COLORED_REGEXP, '') else '' end end
# File lib/cucumber/term/ansicolor.rb, line 111 def version_is_greater_than_18? version = RUBY_VERSION.split('.') version.map! &:to_i version[0] >= 1 && version[1] > 8 end