class TaxGenerator::TaxonomyNode

node from the tree

Public Instance Methods

fetch_prefix_for_printing(level) click to toggle source
builds up the prefix needed to display for current node

@param [Integer] level the level of the current node

@return [String]

@api public

# File lib/tax_generator/classes/taxonomy_node.rb, line 28
def fetch_prefix_for_printing(level)
  prefix = ''
  if is_root?
    prefix << '*'
  else
    prefix << '|' unless parent.is_last_sibling?
    prefix << (' ' * (level - 1) * 4)
    prefix << (is_last_sibling? ? '+' : '|')
    prefix << '---'
    prefix << (has_children? ? '+' : '>')
  end
  prefix
end
print_tree(level = 0, max_depth = nil, block = ->(node, prefix) { puts " click to toggle source
prints the entire tree with name and content

@param [Integer] level the level of the current node, Default 0 @param [Integer] max_depth the maximum depth the tree must be printed. Default nil @param [Lambda] block the lambda that will be executed for printing node name and content

@return [String]

@api public