Class: Lumberjack::Formatter::PrettyPrintFormatter

Inherits:
Object
  • Object
show all
Defined in:
lib/lumberjack/formatter/pretty_print_formatter.rb

Overview

Format an object with it’s pretty print method.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(width = 79) ⇒ PrettyPrintFormatter

Create a new formatter. The maximum width of the message can be specified with the width parameter (defaults to 79 characters).



12
13
14
# File 'lib/lumberjack/formatter/pretty_print_formatter.rb', line 12

def initialize(width = 79)
  @width = width
end

Instance Attribute Details

#widthObject

Returns the value of attribute width.



8
9
10
# File 'lib/lumberjack/formatter/pretty_print_formatter.rb', line 8

def width
  @width
end

Instance Method Details

#call(obj) ⇒ Object



16
17
18
19
20
# File 'lib/lumberjack/formatter/pretty_print_formatter.rb', line 16

def call(obj)
  s = StringIO.new
  PP.pp(obj, s)
  s.string.chomp
end