Class: Rack::Logjam::ANSI

Inherits:
Object
  • Object
show all
Defined in:
lib/rack/logjam/ansi.rb

Class Method Summary collapse

Class Method Details

.chartObject



17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/rack/logjam/ansi.rb', line 17

def self.chart
  {
    black: 30,
    red: 31,
    green: 32,
    yellow: 33,
    blue: 34,
    magenta: 35,
    cyan: 36,
    white: 37
  }
end

.resetObject



13
14
15
# File 'lib/rack/logjam/ansi.rb', line 13

def self.reset
  "\e[0m"
end

.resolve_text(color, &block) ⇒ Object



5
6
7
8
9
10
11
# File 'lib/rack/logjam/ansi.rb', line 5

def self.resolve_text( color, &block )
  text = nil
  if block_given?
    text = block.call + reset
  end
  "\e[#{chart[color.to_sym]}m#{text}"
end