Module: Cased::CLI::Log

Defined in:
lib/cased/cli/log.rb

Constant Summary collapse

CLEAR =
"\e[0m"
YELLOW =
"\e[33m"
BOLD =
"\e[1m"

Class Method Summary collapse

Class Method Details

.color(text, color, bold: false) ⇒ Object



20
21
22
23
24
# File 'lib/cased/cli/log.rb', line 20

def self.color(text, color, bold: false)
  color = self.class.const_get(color.upcase) if color.is_a?(Symbol)
  bold  = bold ? BOLD : ''
  "#{bold}#{color}#{text}#{CLEAR}"
end

.log(text) ⇒ Object



14
15
16
17
18
# File 'lib/cased/cli/log.rb', line 14

def self.log(text)
  puts string(text)
ensure
  $stdout.flush
end

.string(text) ⇒ Object



10
11
12
# File 'lib/cased/cli/log.rb', line 10

def self.string(text)
  [color('[cased]', YELLOW, bold: true), text].join(' ')
end