Class: CobraCommander::CLI::Output::AsciiTree

Inherits:
Object
  • Object
show all
Defined in:
lib/cobra_commander/cli/output/ascii_tree.rb

Overview

Prints the tree in a nice tree form

Constant Summary collapse

SPACE =
"    "
BAR =
"│   "
TEE =
"├── "
CORNER =
"└── "

Instance Method Summary collapse

Constructor Details

#initialize(components) ⇒ AsciiTree

Returns a new instance of AsciiTree.



14
15
16
# File 'lib/cobra_commander/cli/output/ascii_tree.rb', line 14

def initialize(components)
  @components = components.sort_by(&:name)
end

Instance Method Details

#to_sObject



18
19
20
21
22
23
24
25
# File 'lib/cobra_commander/cli/output/ascii_tree.rb', line 18

def to_s
  StringIO.new.tap do |io|
    @components.each do |component|
      io.puts component.name
      list_dependencies(io, component)
    end
  end.string
end