Class: Lumberjack::Formatter::PrettyPrintFormatter
- Inherits:
-
Object
- Object
- Lumberjack::Formatter::PrettyPrintFormatter
- Defined in:
- lib/lumberjack/formatter/pretty_print_formatter.rb
Overview
Format an object with it’s pretty print method.
Instance Attribute Summary collapse
-
#width ⇒ Object
Returns the value of attribute width.
Instance Method Summary collapse
- #call(obj) ⇒ Object
-
#initialize(width = 79) ⇒ PrettyPrintFormatter
constructor
Create a new formatter.
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).
14 15 16 |
# File 'lib/lumberjack/formatter/pretty_print_formatter.rb', line 14 def initialize(width = 79) @width = width end |
Instance Attribute Details
#width ⇒ Object
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
18 19 20 21 22 |
# File 'lib/lumberjack/formatter/pretty_print_formatter.rb', line 18 def call(obj) s = StringIO.new PP.pp(obj, s) s.string.chomp end |