Module: Clash::Helpers

Included in:
Diff, Test, Tests
Defined in:
lib/clash/helpers.rb

Instance Method Summary collapse

Instance Method Details

#boldit(str) ⇒ Object



38
39
40
# File 'lib/clash/helpers.rb', line 38

def boldit(str)
  colorize(str, 'bold')
end

#colorize(str, color) ⇒ Object



9
10
11
12
13
14
15
# File 'lib/clash/helpers.rb', line 9

def colorize(str, color)
  if STDOUT.tty?
    str.send(color)
  else
    str
  end
end

#default_array(option) ⇒ Object



3
4
5
6
7
# File 'lib/clash/helpers.rb', line 3

def default_array(option)
  o = option || []
  o = [o] unless o.is_a?(Array)
  o
end

#greenit(str) ⇒ Object



26
27
28
# File 'lib/clash/helpers.rb', line 26

def greenit(str)
  colorize(str, 'green')
end

#pout(str) ⇒ Object

Print a single character without a newline



19
20
21
22
23
24
# File 'lib/clash/helpers.rb', line 19

def pout(str)
  print str
  if STDOUT.tty?
    $stdout.flush
  end
end


42
43
44
# File 'lib/clash/helpers.rb', line 42

def print_fail
  pout redit('F')
end


46
47
48
# File 'lib/clash/helpers.rb', line 46

def print_pass
  pout greenit('.')
end

#redit(str) ⇒ Object



34
35
36
# File 'lib/clash/helpers.rb', line 34

def redit(str)
  colorize(str, 'red')
end

#yellowit(str) ⇒ Object



30
31
32
# File 'lib/clash/helpers.rb', line 30

def yellowit(str)
  colorize(str, 'yellow')
end