Class: String

Inherits:
Object show all
Defined in:
lib/pretty_debug.rb,
lib/pretty_debug.rb

Constant Summary collapse

@@indent =
"  "

Instance Method Summary collapse

Instance Method Details

#bfObject



217
# File 'lib/pretty_debug.rb', line 217

def bf; "#{vt100("01".freeze)}#{self}#{vt100}" end

#bg(sym) ⇒ Object



222
223
224
# File 'lib/pretty_debug.rb', line 222

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



219
220
221
# File 'lib/pretty_debug.rb', line 219

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



265
266
267
268
269
270
# File 'lib/pretty_debug.rb', line 265

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



261
# File 'lib/pretty_debug.rb', line 261

def indent n = 1; gsub(/^/, @@indent * n) end

#terminal_escapeObject



216
# File 'lib/pretty_debug.rb', line 216

def terminal_escape; "\"#{self}\"" end

#unchompObject



263
# File 'lib/pretty_debug.rb', line 263

def unchomp; sub(/#$/?\z/, $/) end

#unchomp!Object



264
# File 'lib/pretty_debug.rb', line 264

def unchomp!; sub!(/#$/?\z/, $/) end

#underlineObject



218
# File 'lib/pretty_debug.rb', line 218

def underline; "#{vt100("04".freeze)}#{self}#{vt100}" end

#unindentObject



262
# File 'lib/pretty_debug.rb', line 262

def unindent; gsub(/^#{match(/^\s+/)}/, "".freeze).chomp end

#verbatimObject



215
# File 'lib/pretty_debug.rb', line 215

def verbatim; bg(:magenta) end