Class: String

Inherits:
Object show all
Defined in:
lib/ectoplasm.rb

Instance Method Summary collapse

Instance Method Details

#blueObject Also known as: info



19
# File 'lib/ectoplasm.rb', line 19

def blue; colored '34'; end

#boldObject



24
# File 'lib/ectoplasm.rb', line 24

def bold; colored '1'; end

#cyanObject



21
# File 'lib/ectoplasm.rb', line 21

def cyan; colored '36'; end

#frmt(props, prefix_suffix = ['<', '>']) ⇒ Object



45
46
47
48
49
50
51
52
53
54
# File 'lib/ectoplasm.rb', line 45

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

#greenObject Also known as: ok



17
# File 'lib/ectoplasm.rb', line 17

def green; colored '32'; end

#greyObject Also known as: dim



22
# File 'lib/ectoplasm.rb', line 22

def grey; colored '90'; end

#indent(amount, char: ' ') ⇒ Object



33
34
35
# File 'lib/ectoplasm.rb', line 33

def indent amount, char: ' '
  self.split("\n").map { |line| char * amount + line }.join "\n"
end

#lengthObject



37
38
39
40
41
42
43
# File 'lib/ectoplasm.rb', line 37

def length
  m = /\e\[\d{2}m(.*)\e\[0m/.match self

  return self.chars.count - 9 if m

  self.chars.count
end

#magentaObject



20
# File 'lib/ectoplasm.rb', line 20

def magenta; colored '35'; end

#redObject Also known as: error



16
# File 'lib/ectoplasm.rb', line 16

def red; colored '31'; end

#underlineObject



25
# File 'lib/ectoplasm.rb', line 25

def underline; colored '4'; end

#whiteObject



15
# File 'lib/ectoplasm.rb', line 15

def white; self; end

#yellowObject Also known as: warn



18
# File 'lib/ectoplasm.rb', line 18

def yellow; colored '33'; end