module TTY::Color

Responsible for checking terminal color support

@api public

Constants

NoValue
VERSION

Attributes

output[RW]
verbose[RW]

Public Instance Methods

color?()
Alias for: support?
command?(cmd) click to toggle source

Check if command can be run

@return [Boolean]

@api public

# File lib/tty/color.rb, line 67
def command?(cmd)
  !!system(cmd, out: ::File::NULL, err: ::File::NULL)
end
disabled?() click to toggle source

Detect if color support has been disabled with NO_COLOR ENV var.

@return [Boolean]

true when terminal color support has been disabled, false otherwise

@api public

# File lib/tty/color.rb, line 40
def disabled?
  Support.new(ENV, verbose: verbose).disabled?
end
mode() click to toggle source

Check how many colors this terminal supports

@return [Integer]

@api public

# File lib/tty/color.rb, line 49
def mode
  Mode.new(ENV).mode
end
support?() click to toggle source

Check if terminal supports colors

@return [Boolean]

@api public

# File lib/tty/color.rb, line 27
def support?
  Support.new(ENV, verbose: verbose).support?
end
Also aliased as: supports?, color?, supports_color?
supports?()
Alias for: support?
supports_color?()
Alias for: support?
tty?() click to toggle source

Check if output is linked with terminal

@return [Boolean]

@api public

# File lib/tty/color.rb, line 58
def tty?
  output.respond_to?(:tty?) && output.tty?
end
windows?() click to toggle source

Check if Windowz

@return [Boolean]

@api public

# File lib/tty/color.rb, line 76
def windows?
  ::File::ALT_SEPARATOR == "\\"
end