Class: String
Instance Method Summary collapse
- #blue ⇒ Object (also: #info)
- #bold ⇒ Object
- #cyan ⇒ Object
- #frmt(props, prefix_suffix = ['<', '>']) ⇒ Object
- #green ⇒ Object (also: #ok)
- #grey ⇒ Object (also: #dim)
- #indent(amount, char: ' ') ⇒ Object
- #length ⇒ Object
- #magenta ⇒ Object
- #red ⇒ Object (also: #error)
- #underline ⇒ Object
- #white ⇒ Object
- #yellow ⇒ Object (also: #warn)
Instance Method Details
#blue ⇒ Object Also known as: info
19 |
# File 'lib/ectoplasm.rb', line 19 def blue; colored '34'; end |
#bold ⇒ Object
24 |
# File 'lib/ectoplasm.rb', line 24 def bold; colored '1'; end |
#cyan ⇒ Object
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 |
#green ⇒ Object Also known as: ok
17 |
# File 'lib/ectoplasm.rb', line 17 def green; colored '32'; end |
#grey ⇒ Object 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 |
#length ⇒ Object
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 |
#magenta ⇒ Object
20 |
# File 'lib/ectoplasm.rb', line 20 def magenta; colored '35'; end |
#red ⇒ Object Also known as: error
16 |
# File 'lib/ectoplasm.rb', line 16 def red; colored '31'; end |
#underline ⇒ Object
25 |
# File 'lib/ectoplasm.rb', line 25 def underline; colored '4'; end |
#white ⇒ Object
15 |
# File 'lib/ectoplasm.rb', line 15 def white; self; end |
#yellow ⇒ Object Also known as: warn
18 |
# File 'lib/ectoplasm.rb', line 18 def yellow; colored '33'; end |