Class: Kafo::ColorScheme

Inherits:
Object
  • Object
show all
Defined in:
lib/kafo/color_scheme.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ ColorScheme

Returns a new instance of ColorScheme.



10
11
12
13
# File 'lib/kafo/color_scheme.rb', line 10

def initialize(options = {})
  @background = options[:background].nil? ? :dark : options[:background]
  @colors = options[:colors].nil? ? self.class.colors_possible? : options[:colors]
end

Class Method Details

.colors_possible?Boolean

Returns:

  • (Boolean)


6
7
8
# File 'lib/kafo/color_scheme.rb', line 6

def self.colors_possible?
  ::ENV['TERM'] && !`which tput 2> /dev/null`.empty? && `tput colors`.to_i > 0
end

Instance Method Details

#setupObject



15
16
17
18
19
20
21
22
# File 'lib/kafo/color_scheme.rb', line 15

def setup
  HighLine.color_scheme = build_color_scheme
  if @colors
    HighLine.use_color = true
  else
    HighLine.use_color = false
  end
end