Class: String
Constant Summary collapse
- @@indent =
" "
Instance Method Summary collapse
- #bf ⇒ Object
- #bg(sym) ⇒ Object
- #color(sym) ⇒ Object
- #ellipsis(n) ⇒ Object
- #indent(n = 1) ⇒ Object
- #terminal_escape ⇒ Object
- #unchomp ⇒ Object
- #unchomp! ⇒ Object
- #underline ⇒ Object
- #unindent ⇒ Object
- #verbatim ⇒ Object
Instance Method Details
#bf ⇒ Object
222 |
# File 'lib/pretty_debug.rb', line 222 def bf; "#{vt100("01".freeze)}#{self}#{vt100}" end |
#bg(sym) ⇒ Object
227 228 229 |
# File 'lib/pretty_debug.rb', line 227 def bg sym; "#{vt100(40+ {black: 0, red: 1, green: 2, yellow: 3, blue: 4, magenta: 5, cyan: 6, white: 7}[sym.to_sym] )}#{self}#{vt100}" end |
#color(sym) ⇒ Object
224 225 226 |
# File 'lib/pretty_debug.rb', line 224 def color sym; "#{vt100(30+ {black: 0, red: 1, green: 2, yellow: 3, blue: 4, magenta: 5, cyan: 6, white: 7}[sym.to_sym] )}#{self}#{vt100}" end |
#ellipsis(n) ⇒ Object
270 271 272 273 274 275 |
# File 'lib/pretty_debug.rb', line 270 def ellipsis n if length <= n then self elsif n.odd? then "#{slice(0..n/2-3)}...#{slice(-n/2+2..-1)}" else "#{slice(0..n/2-3)}...#{slice(-n/2+1..-1)}" end end |
#indent(n = 1) ⇒ Object
266 |
# File 'lib/pretty_debug.rb', line 266 def indent n = 1; gsub(/^/, @@indent * n) end |
#terminal_escape ⇒ Object
221 |
# File 'lib/pretty_debug.rb', line 221 def terminal_escape; "\"#{self}\"" end |
#unchomp ⇒ Object
268 |
# File 'lib/pretty_debug.rb', line 268 def unchomp; sub(/#$/?\z/, $/) end |
#unchomp! ⇒ Object
269 |
# File 'lib/pretty_debug.rb', line 269 def unchomp!; sub!(/#$/?\z/, $/) end |
#underline ⇒ Object
223 |
# File 'lib/pretty_debug.rb', line 223 def underline; "#{vt100("04".freeze)}#{self}#{vt100}" end |
#unindent ⇒ Object
267 |
# File 'lib/pretty_debug.rb', line 267 def unindent; gsub(/^#{match(/^\s+/)}/, "".freeze).chomp end |
#verbatim ⇒ Object
220 |
# File 'lib/pretty_debug.rb', line 220 def verbatim; bg(:blue) end |