123456789_123456789_123456789_123456789_123456789_

Module: DEBUGGER__::Color

Instance Method Summary

Instance Method Details

#color_pp(obj, width)

See additional method definition at line 50.

[ GitHub ]

  
# File 'lib/debug/color.rb', line 60

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)

[ GitHub ]

  
# File 'lib/debug/color.rb', line 67

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)

See additional method definition at line 36.

[ GitHub ]

  
# File 'lib/debug/color.rb', line 44

def colorize str, color
  if !CONFIG[:no_color]
    irb_colorize str, color
  else
    str
  end
end

#colorize_blue(str)

[ GitHub ]

  
# File 'lib/debug/color.rb', line 97

def colorize_blue(str)
  colorize(str, [:BLUE, :BOLD])
end

#colorize_code(code)

See additional method definition at line 79.

See additional method definition at line 83.

[ GitHub ]

  
# File 'lib/debug/color.rb', line 88

def colorize_code code
  IRB::Color.colorize_code(code, colorable: true)
end

#colorize_cyan(str)

[ GitHub ]

  
# File 'lib/debug/color.rb', line 93

def colorize_cyan(str)
  colorize(str, [:CYAN, :BOLD])
end

#colorize_dim(str)

[ GitHub ]

  
# File 'lib/debug/color.rb', line 105

def colorize_dim(str)
  colorize(str, [:DIM])
end

#colorize_magenta(str)

[ GitHub ]

  
# File 'lib/debug/color.rb', line 101

def colorize_magenta(str)
  colorize(str, [:MAGENTA, :BOLD])
end

#irb_colorize(str, color)

See additional method definition at line 27.

[ GitHub ]

  
# File 'lib/debug/color.rb', line 31

def irb_colorize str, color
  IRB::Color.colorize str, color, colorable: true
end

#with_inspection_error_guard

[ GitHub ]

  
# File 'lib/debug/color.rb', line 109

def with_inspection_error_guard
  yield
rescue Exception => ex
  err_msg = "#{ex.inspect} rescued during inspection"
  string_result = obj.to_s rescue nil

  # don't colorize the string here because it's not from user's application
  if string_result
    %Q{"#{string_result}" from #to_s because #{err_msg}}
  else
    err_msg
  end
end