123456789_123456789_123456789_123456789_123456789_

Class: PowerAssert::Inspector

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

Class Method Summary

Instance Method Summary

Constructor Details

.new(value, indent) ⇒ Inspector

[ GitHub ]

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

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

Instance Method Details

#inspect

[ GitHub ]

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

def inspect
  if PowerAssert.configuration.colorize_message
    if PowerAssert.configuration.inspector == :pp
      width = [IO.console_size[1] - 1 - @indent, 10].max
      IRB::ColorPrinter.pp(@value, '', width)
    else
      IRB::Color.colorize_code(@value.to_s, ignore_error: true)
    end
  else
    if PowerAssert.configuration.inspector == :pp
      PP.pp(@value, '')
    else
      @value.inspect
    end
  end
end