Class: Pry::ColorPrinter
- Defined in:
- lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/pry-0.14.2/lib/pry/color_printer.rb
Overview
PP subclass for streaming inspect output in color.
Class Method Summary collapse
- .default(_output, value, pry_instance) ⇒ Object
- .pp(obj, output = $DEFAULT_OUTPUT, max_width = 79) ⇒ Object
Instance Method Summary collapse
Class Method Details
.default(_output, value, pry_instance) ⇒ Object
11 12 13 14 15 16 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/pry-0.14.2/lib/pry/color_printer.rb', line 11 def self.default(_output, value, pry_instance) pry_instance.pager.open do |pager| pager.print pry_instance.config.output_prefix pp(value, pager, pry_instance.output.width - 1) end end |
.pp(obj, output = $DEFAULT_OUTPUT, max_width = 79) ⇒ Object
18 19 20 21 22 23 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/pry-0.14.2/lib/pry/color_printer.rb', line 18 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 |
Instance Method Details
#pp(object) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/pry-0.14.2/lib/pry/color_printer.rb', line 25 def pp(object) return super unless object.is_a?(String) # Avoid calling Ruby 2.4+ String#pretty_print that prints multiline # Strings prettier text(object.inspect) rescue StandardError => exception raise if exception.is_a?(Pry::Pager::StopPaging) text(highlight_object_literal(inspect_object(object))) end |
#text(str, max_width = str.length) ⇒ Object
37 38 39 40 41 42 43 44 45 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/pry-0.14.2/lib/pry/color_printer.rb', line 37 def text(str, max_width = str.length) if str.include?("\e[") super("#{str}\e[0m", max_width) elsif str.start_with?('#<') || %w[= >].include?(str) super(highlight_object_literal(str), max_width) else super(SyntaxHighlighter.highlight(str), max_width) end end |