Class: PryTheme::ColorTable

Inherits:
Object
  • Object
show all
Defined in:
lib/pry-theme/color_table.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(color_model) ⇒ ColorTable

Returns a new instance of ColorTable.



24
25
26
# File 'lib/pry-theme/color_table.rb', line 24

def initialize(color_model)
  @color_model = color_model
end

Class Method Details

.build_color_string(color, fg = nil) ⇒ Object



17
18
19
20
21
# File 'lib/pry-theme/color_table.rb', line 17

def build_color_string(color, fg = nil)
  "%s%s\e[0m:%s%s\e[0m" %
    [color.to_ansi(true), fg || color.foreground,
     color.to_ansi, color.foreground(true)]
end

.t16Object



9
10
11
# File 'lib/pry-theme/color_table.rb', line 9

def t16
  ColorTable.new(16).table
end

.t256Object



5
6
7
# File 'lib/pry-theme/color_table.rb', line 5

def t256
  ColorTable.new(256).table
end

.t8Object



13
14
15
# File 'lib/pry-theme/color_table.rb', line 13

def t8
  ColorTable.new(8).table
end

Instance Method Details

#tableObject



28
29
30
31
32
33
34
35
36
# File 'lib/pry-theme/color_table.rb', line 28

def table
  colors = []
  0.upto(@color_model - 1) { |i|
    color = PryTheme.const_get(:"Color#@color_model").new(
      :from => :term, :foreground => i)
    colors << self.class.build_color_string(color, i)
  }
  Pry::Helpers.tablify_or_one_line("Color model #@color_model", colors)
end