module Parlour::Debugging::Tree
A module for generating a globally-consistent, nicely-formatted tree of output using Unicode block characters.
Constants
- INDENT_SPACES
The number of spaces to indent each layer of the tree by. Should be at least 1.
Public Class Methods
begin(message)
click to toggle source
# File lib/parlour/debugging.rb, line 81 def self.begin(message) result = line_prefix + '├' + text_prefix + Rainbow(message).green.bright.bold @indent_level += 1 result end
end(message)
click to toggle source
# File lib/parlour/debugging.rb, line 100 def self.end(message) result = line_prefix + '└' + text_prefix + message @indent_level = [0, @indent_level - 1].max result end
here(message)
click to toggle source
# File lib/parlour/debugging.rb, line 91 def self.here(message) line_prefix + '├' + text_prefix + message end
line_prefix()
click to toggle source
The prefix which should be printed before anything else on this line of the tree, based on the current indent level. @return [String]
# File lib/parlour/debugging.rb, line 109 def self.line_prefix @indent_level.times.map { '│' + ' ' * INDENT_SPACES }.join end
text_prefix()
click to toggle source
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. @return [String]
# File lib/parlour/debugging.rb, line 117 def self.text_prefix '─' * (INDENT_SPACES - 1) + " " end