Module: Parlour::Debugging::Tree
- Extended by:
- T::Sig
- Defined in:
- lib/parlour/debugging.rb
Overview
A module for generating a globally-consistent, nicely-formatted tree of output using Unicode block characters.
Constant Summary collapse
- INDENT_SPACES =
The number of spaces to indent each layer of the tree by. Should be at least 1.
2
Class Method Summary collapse
- .begin(message) ⇒ Object
- .end(message) ⇒ Object
- .here(message) ⇒ Object
-
.line_prefix ⇒ String
The prefix which should be printed before anything else on this line of the tree, based on the current indent level.
-
.text_prefix ⇒ String
The horizontal lines which should be printed between the beginning of the current element and its text, based on the specified number of spaces to use for indents.
Class Method Details
.begin(message) ⇒ Object
81 82 83 84 85 |
# File 'lib/parlour/debugging.rb', line 81 def self.begin() result = line_prefix + '├' + text_prefix + Rainbow().green.bright.bold @indent_level += 1 result end |
.end(message) ⇒ Object
100 101 102 103 104 |
# File 'lib/parlour/debugging.rb', line 100 def self.end() result = line_prefix + '└' + text_prefix + @indent_level = [0, @indent_level - 1].max result end |
.here(message) ⇒ Object
91 92 93 |
# File 'lib/parlour/debugging.rb', line 91 def self.here() line_prefix + '├' + text_prefix + end |
.line_prefix ⇒ String
The prefix which should be printed before anything else on this line of the tree, based on the current indent level.
109 110 111 |
# File 'lib/parlour/debugging.rb', line 109 def self.line_prefix @indent_level.times.map { '│' + ' ' * INDENT_SPACES }.join end |
.text_prefix ⇒ String
The horizontal lines which should be printed between the beginning of the current element and its text, based on the specified number of spaces to use for indents.
117 118 119 |
# File 'lib/parlour/debugging.rb', line 117 def self.text_prefix '─' * (INDENT_SPACES - 1) + " " end |