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).

Parameters:

  • width (Integer) (defaults to: 79)

    The maximum width of the message.



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

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

Instance Attribute Details

#widthObject

Returns the value of attribute width.



10
11
12
# File 'lib/lumberjack/formatter/pretty_print_formatter.rb', line 10

def width
  @width
end

Instance Method Details

#call(obj) ⇒ Object



20
21
22
23
24
# File 'lib/lumberjack/formatter/pretty_print_formatter.rb', line 20

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