Module: ShellColors

Included in:
Location, Schedule, Sport, Weather
Defined in:
lib/bbc/shell/colors.rb

Overview

Outputs the input in technicolour, for a happier terminal.

Useful list of colour codes misc.flogisoft.com/bash/tip_colors_and_formatting

And alternatives stackoverflow.com/questions/1108767/terminal-color-in-ruby

Class Method Summary collapse

Class Method Details

.blue(txt) ⇒ Object



28
29
30
# File 'lib/bbc/shell/colors.rb', line 28

def blue(txt)
  paint(txt, 34)
end

.cyan(txt) ⇒ Object



32
33
34
# File 'lib/bbc/shell/colors.rb', line 32

def cyan(txt)
  paint(txt, 36)
end

.green(txt) ⇒ Object



20
21
22
# File 'lib/bbc/shell/colors.rb', line 20

def green(txt)
  paint(txt, 32)
end

.light_green(txt) ⇒ Object



40
41
42
# File 'lib/bbc/shell/colors.rb', line 40

def light_green(txt)
  paint(txt, 92)
end

.paint(txt, color) ⇒ Object



12
13
14
# File 'lib/bbc/shell/colors.rb', line 12

def paint(txt, color)
  "\033[#{color}m#{txt}\033[0m"
end

.red(txt) ⇒ Object



16
17
18
# File 'lib/bbc/shell/colors.rb', line 16

def red(txt)
  paint(txt, 31)
end

.white(txt) ⇒ Object



36
37
38
# File 'lib/bbc/shell/colors.rb', line 36

def white(txt)
  paint(txt, 37)
end

.yellow(txt) ⇒ Object



24
25
26
# File 'lib/bbc/shell/colors.rb', line 24

def yellow(txt)
  paint(txt, 33)
end