In Files

  • irb/color_printer.rb

Parent

Methods

IRB::ColorPrinter

Public Class Methods

pp(obj, out = $>, width = screen_width) click to toggle source
 
               # File irb/color_printer.rb, line 7
def pp(obj, out = $>, width = screen_width)
  q = ColorPrinter.new(out, width)
  q.guard_inspect_key {q.pp obj}
  q.flush
  out << "\n"
end
            

Public Instance Methods

pp(obj) click to toggle source
 
               # File irb/color_printer.rb, line 23
def pp(obj)
  if obj.is_a?(String)
    # Avoid calling Ruby 2.4+ String#pretty_print that splits a string by "\n"
    text(obj.inspect)
  else
    super
  end
end
            
text(str, width = nil) click to toggle source
 
               # File irb/color_printer.rb, line 32
def text(str, width = nil)
  unless str.is_a?(String)
    str = str.inspect
  end
  width ||= str.length

  case str
  when /\A#</, '=', '>'
    super(Color.colorize(str, [:GREEN]), width)
  else
    super(Color.colorize_code(str, ignore_error: true), width)
  end
end
            
There is an updated format of the API docs for this version here.