color_pp(obj, width)
click to toggle source
def color_pp obj, width
with_inspection_error_guard do
if !CONFIG[:no_color]
IRB::ColorPrinter.pp(obj, "".dup, width)
else
obj.pretty_inspect
end
end
end
colored_inspect(obj, width: SESSION.width, no_color: false)
click to toggle source
def colored_inspect obj, width: SESSION.width, no_color: false
with_inspection_error_guard do
if !no_color
color_pp obj, width
else
obj.pretty_inspect
end
end
end
colorize(str, color)
click to toggle source
def colorize str, color
if !CONFIG[:no_color]
irb_colorize str, color
else
str
end
end
colorize_blue(str)
click to toggle source
def colorize_blue(str)
colorize(str, [:BLUE, :BOLD])
end
colorize_code(code)
click to toggle source
def colorize_code code
IRB::Color.colorize_code(code, colorable: true)
end
colorize_cyan(str)
click to toggle source
def colorize_cyan(str)
colorize(str, [:CYAN, :BOLD])
end
colorize_dim(str)
click to toggle source
def colorize_dim(str)
colorize(str, [:DIM])
end
colorize_magenta(str)
click to toggle source
def colorize_magenta(str)
colorize(str, [:MAGENTA, :BOLD])
end
irb_colorize(str, color)
click to toggle source
def irb_colorize str, color
IRB::Color.colorize str, color, colorable: true
end
with_inspection_error_guard()
click to toggle source
def with_inspection_error_guard
yield
rescue Exception => ex
err_msg = "#{ex.inspect} rescued during inspection"
string_result = obj.to_s rescue nil
if string_result
%Q{"#{string_result}" from #to_s because #{err_msg}}
else
err_msg
end
end