Module: TTY::Color
- Extended by:
- Color
- Included in:
- Color
- Defined in:
- lib/tty/color.rb,
lib/tty/color/mode.rb,
lib/tty/color/support.rb,
lib/tty/color/version.rb
Overview
Responsible for checking terminal color support
Defined Under Namespace
Constant Summary collapse
- NoValue =
Module.new
- VERSION =
"0.6.0"
Instance Attribute Summary collapse
Instance Method Summary collapse
-
#command?(cmd) ⇒ Boolean
Check if command can be run.
-
#disabled? ⇒ Boolean
Detect if color support has been disabled with NO_COLOR ENV var.
-
#mode ⇒ Integer
Check how many colors this terminal supports.
-
#support? ⇒ Boolean
(also: #supports?, #color?, #supports_color?)
Check if terminal supports colors.
-
#tty? ⇒ Boolean
Check if output is linked with terminal.
-
#windows? ⇒ Boolean
Check if Windowz.
Instance Attribute Details
#output ⇒ Object
20 21 22 |
# File 'lib/tty/color.rb', line 20 def output @output end |
#verbose ⇒ Object
20 21 22 |
# File 'lib/tty/color.rb', line 20 def verbose @verbose end |
Instance Method Details
#command?(cmd) ⇒ Boolean
Check if command can be run
67 68 69 |
# File 'lib/tty/color.rb', line 67 def command?(cmd) !!system(cmd, out: ::File::NULL, err: ::File::NULL) end |
#disabled? ⇒ Boolean
Detect if color support has been disabled with NO_COLOR ENV var.
40 41 42 |
# File 'lib/tty/color.rb', line 40 def disabled? Support.new(ENV, verbose: verbose).disabled? end |
#mode ⇒ Integer
Check how many colors this terminal supports
49 50 51 |
# File 'lib/tty/color.rb', line 49 def mode Mode.new(ENV).mode end |
#support? ⇒ Boolean Also known as: supports?, color?, supports_color?
Check if terminal supports colors
27 28 29 |
# File 'lib/tty/color.rb', line 27 def support? Support.new(ENV, verbose: verbose).support? end |
#tty? ⇒ Boolean
Check if output is linked with terminal
58 59 60 |
# File 'lib/tty/color.rb', line 58 def tty? output.respond_to?(:tty?) && output.tty? end |
#windows? ⇒ Boolean
Check if Windowz
76 77 78 |
# File 'lib/tty/color.rb', line 76 def windows? ::File::ALT_SEPARATOR == "\\" end |