Class: BlastRadius::Formatters::TextFormatter

Inherits:
Base
  • Object
show all
Defined in:
lib/blast_radius/formatters/text_formatter.rb

Constant Summary collapse

TREE_BRANCH =
'├── '
TREE_LAST =
'└── '
TREE_VERTICAL =
''
TREE_SPACE =
'    '

Instance Method Summary collapse

Methods inherited from Base

#initialize

Constructor Details

This class inherits a constructor from BlastRadius::Formatters::Base

Instance Method Details

#format(root_node) ⇒ String

Format dependency tree as ASCII tree

Parameters:

  • root_node (Node)

    root node of dependency tree

Returns:

  • (String)

    ASCII tree representation



14
15
16
17
18
# File 'lib/blast_radius/formatters/text_formatter.rb', line 14

def format(root_node)
  lines = [root_node.model_name]
  format_children(root_node.children, '', lines)
  lines.join("\n")
end