Sha256: de3e5538baabc6ee577b83cc6db5531ef31e3a9aaef15cbdde693feab35294b3
Contents?: true
Size: 946 Bytes
Versions: 1
Compression:
Stored size: 946 Bytes
Contents
# frozen_string_literal: true module Helium class Console class ColorPrinter < Pry::ColorPrinter def self.pp(obj, output = $DEFAULT_OUTPUT, max_width = 79) queue = ColorPrinter.new(output, max_width, "\n") queue.guard_inspect_key { queue.pp(obj) } queue.flush output << "\n" end def pp(object) formatted = Helium::Console.format(object, max_width: maxwidth) output << "\n" if multiline?(formatted) formatted.lines.each.with_index do |line, index| output << "\n" unless index.zero? output << line.chomp end end def multiline?(formatted) result = formatted.is_a?(Formatter::LazyStringEvaluator) result ||= formatted.lines.count > 1 result || length_of(formatted.chomp) >= maxwidth - 2 end def length_of(str) ColorizedString.new(str).uncolorize.length end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
helium-console-0.1.13 | lib/helium/console/printer.rb |