Module: Sai::Support

Defined in:
lib/sai/support.rb

Overview

Determine the color capabilities of the terminal

Author:

Since:

  • 0.1.0

Class Method Summary collapse

Class Method Details

.advanced? ⇒ Boolean Also known as: color256?, colour256?, eight_bit?, two_hundred_fifty_six_color?, two_hundred_fifty_six_colour?

Check if the terminal supports 256 colors (8-bit)

Examples:

Check if the terminal supports 256 colors

Sai.advanced? # => true

Returns:

  • (Boolean) —

    true if the terminal supports 256 colors (8-bit), otherwise false

Author:

Since:

  • 0.1.0



27
28
29
# File 'lib/sai/support.rb', line 27

def advanced?
  Terminal::Capabilities.detect_color_support >= Terminal::ColorMode::ADVANCED
end

.ansi? ⇒ Boolean Also known as: color16?, colour16?, four_bit?, sixteen_color?, sixteen_colour?

Check if the terminal supports ANSI colors (4-bit)

Examples:

Check if the terminal supports ANSI colors

Sai.ansi? # => true

Returns:

  • (Boolean) —

    true if the terminal supports ANSI colors (4-bit), otherwise false

Author:

Since:

  • 0.1.0



48
49
50
# File 'lib/sai/support.rb', line 48

def ansi?
  Terminal::Capabilities.detect_color_support >= Terminal::ColorMode::ANSI
end

.basic? ⇒ Boolean Also known as: color8?, colour8?, eight_color?, eight_colour?, three_bit?

Check if the terminal supports basic colors (3-bit)

Examples:

Check if the terminal supports basic colors

Sai.basic? # => true

Returns:

  • (Boolean) —

    true if the terminal supports basic colors (3-bit), otherwise false

Author:

Since:

  • 0.1.0



69
70
71
# File 'lib/sai/support.rb', line 69

def basic?
  Terminal::Capabilities.detect_color_support >= Terminal::ColorMode::BASIC
end

.color? ⇒ Boolean

Check if the terminal supports color output

Examples:

Check if the terminal supports color

Sai.color? # => true

Returns:

  • (Boolean) —

    true if the terminal supports color output, otherwise false

Author:

Since:

  • 0.1.0



90
91
92
# File 'lib/sai/support.rb', line 90

def color?
  Terminal::Capabilities.detect_color_support > Terminal::ColorMode::NO_COLOR
end

.true_color? ⇒ Boolean Also known as: color16m?, colour16m?, sixteen_million_color?, sixteen_million_colour?, twenty_for_bit?

Check if the terminal supports true color (24-bit)

Examples:

Check if the terminal supports true color

Sai.true_color? # => true

Returns:

  • (Boolean) —

    true if the terminal supports true color (24-bit), otherwise false

Author:

Since:

  • 0.1.0



106
107
108
# File 'lib/sai/support.rb', line 106

def true_color?
  Terminal::Capabilities.detect_color_support >= Terminal::ColorMode::TRUE_COLOR
end