Sha256: c8913c9efe24bda6d681235dbcc23e1ac95ab99e49afd0645c43d9a18e1b1022

Contents?: true

Size: 590 Bytes

Versions: 2

Compression:

Stored size: 590 Bytes

Contents

# frozen_string_literal: true
require 'pp'
require 'irb/color'

module IRB
  class ColorPrinter < ::PP
    def self.pp(obj, out = $>, width = 79)
      q = ColorPrinter.new(out, width)
      q.guard_inspect_key {q.pp obj}
      q.flush
      out << "\n"
    end

    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
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
irb-1.3.2 lib/irb/color_printer.rb
irb-1.3.1 lib/irb/color_printer.rb