123456789_123456789_123456789_123456789_123456789_

Class: PowerAssert::Formatter

Relationships & Source Files
Inherits: Object
Defined in: lib/power_assert/inspector.rb

Class Method Summary

Instance Method Summary

Constructor Details

.new(value, indent) ⇒ Formatter

[ GitHub ]

  
# File 'lib/power_assert/inspector.rb', line 38

def initialize(value, indent)
  @value = value
  @indent = indent
end

Instance Method Details

#inspect

[ GitHub ]

  
# File 'lib/power_assert/inspector.rb', line 43

def inspect
  if PowerAssert.configuration._colorize_message
    if PowerAssert.configuration._use_pp
      width = [(defined?(Pry::Terminal) ? Pry::Terminal.width! : Pry.new(output: StringIO.new).output.width) - 1 - @indent, 10].max
      Pry::ColorPrinter.pp(@value, '', width)
    else
      Pry::Code.new(@value.inspect).highlighted
    end
  else
    if PowerAssert.configuration._use_pp
      PP.pp(@value, '')
    else
      @value.inspect
    end
  end
end