Class: String

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

Overview

add some colors, windowing methods

Instance Method Summary collapse

Instance Method Details

#bluObject



32
33
34
# File 'lib/bookmarks.rb', line 32

def blu
  colorize(34, 0)
end

#colorize(color, mod) ⇒ Object



24
25
26
# File 'lib/bookmarks.rb', line 24

def colorize(color, mod)
  "\033[#{mod};#{color};49m#{self}\033[0;0m"
end

#cyanObject



36
37
38
# File 'lib/bookmarks.rb', line 36

def cyan
  colorize(36, 0)
end

#grnObject



44
45
46
# File 'lib/bookmarks.rb', line 44

def grn
  colorize(32, 0)
end

#redObject



48
49
50
# File 'lib/bookmarks.rb', line 48

def red
  colorize(31, 0)
end

#resetObject



28
29
30
# File 'lib/bookmarks.rb', line 28

def reset
  colorize(0, 0)
end

#window(width) ⇒ Object



16
17
18
19
20
21
22
# File 'lib/bookmarks.rb', line 16

def window(width)
  if length >= width
    self[0..width - 1]
  else
    ljust(width)
  end
end

#yelObject



40
41
42
# File 'lib/bookmarks.rb', line 40

def yel
  colorize(33, 0)
end