class String
Public Class Methods
colored!()
click to toggle source
# File lib/ectoplasm.rb, line 17 def self.colored! @@colored = true end
Public Instance Methods
blue()
click to toggle source
# File lib/ectoplasm.rb, line 25 def blue; colored '34'; end
Also aliased as: info
cyan()
click to toggle source
# File lib/ectoplasm.rb, line 27 def cyan; colored '36'; end
frmt(props, prefix_suffix=['<', '>'])
click to toggle source
# File lib/ectoplasm.rb, line 46 def frmt props, prefix_suffix=['<', '>'] str = self props.keys.each do |key| placeholder = prefix_suffix[0] + key.to_s + prefix_suffix[1] str = str.gsub(placeholder, props[key]) end str end
green()
click to toggle source
# File lib/ectoplasm.rb, line 23 def green; colored '32'; end
Also aliased as: ok
grey()
click to toggle source
# File lib/ectoplasm.rb, line 28 def grey; colored '90'; end
Also aliased as: dim
indent(amount, char: ' ')
click to toggle source
# File lib/ectoplasm.rb, line 36 def indent amount, char: ' ' self.split("\n").map { |line| char * amount + line }.join "\n" end
length()
click to toggle source
# File lib/ectoplasm.rb, line 40 def length m = /\e\[\d{2}m(.*)\e\[0m/.match self return self.chars.count - 9 if m self.chars.count end
magenta()
click to toggle source
# File lib/ectoplasm.rb, line 26 def magenta; colored '35'; end
red()
click to toggle source
# File lib/ectoplasm.rb, line 22 def red; colored '31'; end
Also aliased as: error
white()
click to toggle source
# File lib/ectoplasm.rb, line 21 def white; self; end
yellow()
click to toggle source
# File lib/ectoplasm.rb, line 24 def yellow; colored '33'; end
Also aliased as: warn
Private Instance Methods
colored(ansi_color)
click to toggle source
# File lib/ectoplasm.rb, line 59 def colored ansi_color return self if !@@colored "\e[#{ansi_color}m#{self}\e[0m" end