Class: String

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

Instance Method Summary collapse

Instance Method Details

#colorize(color_code) ⇒ Object

colorization



5
6
7
# File 'lib/ra10ke/monkey_patches.rb', line 5

def colorize(color_code)
  "\e[#{color_code}m#{self}\e[0m"
end

#greenObject



13
14
15
# File 'lib/ra10ke/monkey_patches.rb', line 13

def green
  colorize(32)
end

#redObject



9
10
11
# File 'lib/ra10ke/monkey_patches.rb', line 9

def red
  colorize(31)
end

#strip_comment(markers = ['#', "\n"]) ⇒ String

removes specified markes from string.

Returns:

  • (String)
    • the string with markers removed



23
24
25
26
27
# File 'lib/ra10ke/monkey_patches.rb', line 23

def strip_comment(markers = ['#', "\n"])
  re = Regexp.union(markers)
  index = (self =~ re)
  index.nil? ? rstrip : self[0, index].rstrip
end

#yellowObject



17
18
19
# File 'lib/ra10ke/monkey_patches.rb', line 17

def yellow
  colorize(33)
end