Class: Kapnismology::Terminal

Inherits:
Object
  • Object
show all
Defined in:
lib/kapnismology/terminal.rb

Class Method Summary collapse

Class Method Details

.bold(msg) ⇒ Object



15
16
17
# File 'lib/kapnismology/terminal.rb', line 15

def self.bold(msg)
  colorize(msg, '')
end

.colorize(msg, color_code) ⇒ Object



19
20
21
22
# File 'lib/kapnismology/terminal.rb', line 19

def self.colorize(msg, color_code)
  # \e[1m adds bold font, \e[0m resets all styles
  $stdout.isatty ? "#{color_code}\e[1m#{msg}\e[0m" : msg
end

.green(msg) ⇒ Object



3
4
5
# File 'lib/kapnismology/terminal.rb', line 3

def self.green(msg)
  colorize(msg, "\e[32m")
end

.red(msg) ⇒ Object



7
8
9
# File 'lib/kapnismology/terminal.rb', line 7

def self.red(msg)
  colorize(msg, "\e[31m")
end

.yellow(msg) ⇒ Object



11
12
13
# File 'lib/kapnismology/terminal.rb', line 11

def self.yellow(msg)
  colorize(msg, "\e[33m")
end