class IRB::ColorPrinter

Public Class Methods

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

Public Instance Methods

text(str, width = nil) click to toggle source
Calls superclass method PrettyPrint#text
# File lib/irb/color_printer.rb, line 14
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