Module: XMP2Assert::PrettierInspect

Included in:
Quasifile
Defined in:
lib/xmp2assert/prettier_inspect.rb

Overview

By including this module your class gets a #inspect method which uses PP methods to control outputs. You don't have to worry about redefining both. Just define your #pretty_print and that should also work for inspection.

Instance Method Summary collapse

Instance Method Details

#inspectObject

Prettier inspection.



37
38
39
40
41
# File 'lib/xmp2assert/prettier_inspect.rb', line 37

def inspect
  str = PP.pp self, '', Float::INFINITY
  str.chomp!
  return str
end

#pretty_print(pp) ⇒ Object

System-provided pretty print honors #inspect when present but we don't like that. Force it behave as if inspect wasn't there.

Parameters:

  • pp (PP)

    pp.



47
48
49
# File 'lib/xmp2assert/prettier_inspect.rb', line 47

def pretty_print pp
  pp.pp_object self
end