Class: Benchin::Wrap::Report::NodePrinter Private

Inherits:
Object
  • Object
show all
Defined in:
lib/benchin/wrap/report/node_printer.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Human readable Node printing.

With TTY colors.

Constant Summary collapse

FIELD_SPACE =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

14
VALUE_SPACE =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

7
PRECISION =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

3

Instance Method Summary collapse

Constructor Details

#initialize(node, level: 0) ⇒ NodePrinter

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of NodePrinter.


18
19
20
21
# File 'lib/benchin/wrap/report/node_printer.rb', line 18

def initialize(node, level: 0)
  @node = node
  @level = level
end

Instance Method Details

#to_sString

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns rendered report.


24
25
26
27
28
29
30
31
# File 'lib/benchin/wrap/report/node_printer.rb', line 24

def to_s
  [
    (@node.is_a?(Node::Virtual) ? virtual_body : body),
    @node.nested.values.map do |child_node|
      self.class.new(child_node, level: @level + 1).to_s
    end
  ].flatten.join("\n")
end