class Treedent::NodeDrawing

Constants

BAR
CORNER
SPACE
TEE

Public Instance Methods

drawings() click to toggle source
# File lib/treedent/node_drawing.rb, line 12
def drawings
  return [] if node.orphan?
  [outer_indentation, inner_indentation].flatten
end
to_s() click to toggle source
# File lib/treedent/node_drawing.rb, line 8
def to_s
  [drawings, node.value.content].compact.join
end

Private Instance Methods

inner_indentation() click to toggle source
# File lib/treedent/node_drawing.rb, line 19
def inner_indentation
  if node.final_sibling?
    CORNER
  else
    TEE
  end
end
outer_indentation() click to toggle source
# File lib/treedent/node_drawing.rb, line 27
def outer_indentation
  node.ancestors.reverse_each.map do |parent|
    next if parent.root? || parent.orphan?

    if parent.final_sibling?
      SPACE
    else
      BAR
    end
  end
end