Class: String

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

Instance Method Summary collapse

Instance Method Details

#bg_blackObject



11
# File 'lib/core_ext/string.rb', line 11

def bg_black;       "\033[40m#{self}\033[0m" end

#bg_blueObject



15
# File 'lib/core_ext/string.rb', line 15

def bg_blue;        "\033[44m#{self}\033[0m" end

#bg_brownObject



14
# File 'lib/core_ext/string.rb', line 14

def bg_brown;       "\033[43m#{self}\033[0m" end

#bg_cyanObject



17
# File 'lib/core_ext/string.rb', line 17

def bg_cyan;        "\033[46m#{self}\033[0m" end

#bg_grayObject



18
# File 'lib/core_ext/string.rb', line 18

def bg_gray;        "\033[47m#{self}\033[0m" end

#bg_greenObject



13
# File 'lib/core_ext/string.rb', line 13

def bg_green;       "\033[42m#{self}\033[0m" end

#bg_magentaObject



16
# File 'lib/core_ext/string.rb', line 16

def bg_magenta;     "\033[45m#{self}\033[0m" end

#bg_redObject



12
# File 'lib/core_ext/string.rb', line 12

def bg_red;         "\033[41m#{self}\033[0m" end

#blackObject



3
# File 'lib/core_ext/string.rb', line 3

def black;          "\033[30m#{self}\033[0m" end

#blueObject



7
# File 'lib/core_ext/string.rb', line 7

def blue;           "\033[34m#{self}\033[0m" end

#boldObject



19
# File 'lib/core_ext/string.rb', line 19

def bold;           "\033[1m#{self}\033[22m" end

#brownObject



6
# File 'lib/core_ext/string.rb', line 6

def brown;          "\033[33m#{self}\033[0m" end

#cyanObject



9
# File 'lib/core_ext/string.rb', line 9

def cyan;           "\033[36m#{self}\033[0m" end

#grayObject



10
# File 'lib/core_ext/string.rb', line 10

def gray;           "\033[37m#{self}\033[0m" end

#greenObject



5
# File 'lib/core_ext/string.rb', line 5

def green;          "\033[32m#{self}\033[0m" end

#magentaObject



8
# File 'lib/core_ext/string.rb', line 8

def magenta;        "\033[35m#{self}\033[0m" end

#randomize_colorObject



22
23
24
# File 'lib/core_ext/string.rb', line 22

def randomize_color
  "\033[3#{self.hash % 6 + 1}m#{self}\033[0m"
end

#redObject



4
# File 'lib/core_ext/string.rb', line 4

def red;            "\033[31m#{self}\033[0m" end

#reverse_colorObject



20
# File 'lib/core_ext/string.rb', line 20

def reverse_color;  "\033[7m#{self}\033[27m" end

#trim_and_rjust(len) ⇒ Object



26
27
28
29
30
31
32
# File 'lib/core_ext/string.rb', line 26

def trim_and_rjust(len)
  if self.length > len
    self[0 .. (len/2 - 2)] + ".." + self[-(len/2) .. -1]
  else
    self.rjust len
  end
end