Class: String

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

Constant Summary collapse

@@is_a_tty =

colorization

nil

Instance Method Summary collapse

Instance Method Details

#blueObject



35
36
37
# File 'lib/common.rb', line 35

def blue
    colorize(34)
end

#brownObject



31
32
33
# File 'lib/common.rb', line 31

def brown
    colorize(33)
end

#colorize(color_code) ⇒ Object



14
15
16
17
18
19
20
21
# File 'lib/common.rb', line 14

def colorize(color_code)
    @@is_a_tty = STDOUT.isatty() if @@is_a_tty == nil
    if @@is_a_tty then
        return "\e[#{color_code}m#{self}\e[0m"
    else
        return self
    end
end

#greenObject



27
28
29
# File 'lib/common.rb', line 27

def green
    colorize(32)
end

#magentaObject



39
40
41
# File 'lib/common.rb', line 39

def magenta
    colorize(35)
end

#redObject



23
24
25
# File 'lib/common.rb', line 23

def red
    colorize(31)
end