Class: TTY::Tree::NumberRenderer
- Inherits:
-
Object
- Object
- TTY::Tree::NumberRenderer
- Defined in:
- lib/tty/tree/number_renderer.rb
Overview
Render nodes as numbered list
Instance Method Summary collapse
-
#initialize(nodes, options = {}) ⇒ NumberRenderer
constructor
A new instance of NumberRenderer.
- #render ⇒ Object
Constructor Details
#initialize(nodes, options = {}) ⇒ NumberRenderer
Returns a new instance of NumberRenderer.
7 8 9 10 11 |
# File 'lib/tty/tree/number_renderer.rb', line 7 def initialize(nodes, = {}) @indent = .fetch(:indent, 4) @nodes = nodes @mark = ' ' * @indent end |
Instance Method Details
#render ⇒ Object
13 14 15 16 17 |
# File 'lib/tty/tree/number_renderer.rb', line 13 def render @nodes.each_with_index.reduce([]) do |acc, (node, i)| render_node(acc, node, i, @mark) end.join end |