Class: String
Constant Summary collapse
- @@indent =
" "
Instance Method Summary collapse
- #bf ⇒ Object
- #bg(sym) ⇒ Object
- #color(sym) ⇒ Object
- #de_vt100 ⇒ Object
- #ellipsis(n) ⇒ Object
- #indent(n = 1) ⇒ Object
- #terminal_escape ⇒ Object
- #unchomp ⇒ Object
- #unchomp! ⇒ Object
- #underline ⇒ Object
- #verbatim ⇒ Object
Instance Method Details
#bf ⇒ Object
281 |
# File 'lib/pretty_debug.rb', line 281 def bf; "#{vt100("01")}#{self}#{vt100}" end |
#bg(sym) ⇒ Object
286 287 288 |
# File 'lib/pretty_debug.rb', line 286 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
283 284 285 |
# File 'lib/pretty_debug.rb', line 283 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 |
#de_vt100 ⇒ Object
289 |
# File 'lib/pretty_debug.rb', line 289 def de_vt100; gsub(/\e\[\d*m/, "") end |
#ellipsis(n) ⇒ Object
328 329 330 331 332 333 |
# File 'lib/pretty_debug.rb', line 328 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
325 |
# File 'lib/pretty_debug.rb', line 325 def indent n = 1; gsub(/^/, @@indent * n) end |
#terminal_escape ⇒ Object
280 |
# File 'lib/pretty_debug.rb', line 280 def terminal_escape; "\"#{self}\"" end |
#unchomp ⇒ Object
326 |
# File 'lib/pretty_debug.rb', line 326 def unchomp; sub(/#$/?\z/, $/) end |
#unchomp! ⇒ Object
327 |
# File 'lib/pretty_debug.rb', line 327 def unchomp!; sub!(/#$/?\z/, $/) end |
#underline ⇒ Object
282 |
# File 'lib/pretty_debug.rb', line 282 def underline; "#{vt100("04")}#{self}#{vt100}" end |
#verbatim ⇒ Object
279 |
# File 'lib/pretty_debug.rb', line 279 def verbatim; bg(:blue) end |