Class: RubyMethodTracer::Formatters::TreeFormatter
- Inherits:
-
BaseFormatter
- Object
- BaseFormatter
- RubyMethodTracer::Formatters::TreeFormatter
- Defined in:
- lib/ruby_method_tracer/formatters/tree_formatter.rb
Overview
TreeFormatter generates hierarchical tree visualizations of method calls
Instance Method Summary collapse
-
#format(call_tree, options = {}) ⇒ String
Format call tree into hierarchical string representation.
Methods inherited from BaseFormatter
Instance Method Details
#format(call_tree, options = {}) ⇒ String
Format call tree into hierarchical string representation
rubocop:disable Metrics/AbcSize
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/ruby_method_tracer/formatters/tree_formatter.rb', line 17 def format(call_tree, = {}) opts = .merge() root_calls = call_tree.call_hierarchy return "No method calls recorded.\n" if root_calls.empty? output = [] output << header output << separator root_calls.each_with_index do |call, index| is_last_root = index == root_calls.size - 1 output << format_call_node(call, "", is_last_root, opts) output << "" unless is_last_root # Blank line between root calls end output << separator output << format_statistics(call_tree.statistics, opts) output.join("\n") end |