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.



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

def inspect
  str = PP.singleline_pp self, ''
  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.



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

def pretty_print pp
  pp.pp_object self
end