Module: TTY::Table::Indentation
- Defined in:
- lib/tty/table/indentation.rb
Overview
A module responsible for indenting table representation
Class Method Summary collapse
-
.indent(part, indentation) ⇒ Object
Return a table part with indentation inserted.
-
.insert_indentation(line, indentation) ⇒ String
Insert indentation into a table renderd line.
Class Method Details
.indent(part, indentation) ⇒ Object
Return a table part with indentation inserted
13 14 15 16 17 18 19 |
# File 'lib/tty/table/indentation.rb', line 13 def indent(part, indentation) if part.is_a?(Enumerable) && part.respond_to?(:to_a) part.map { |line| insert_indentation(line, indentation) } else insert_indentation(part, indentation) end end |
.insert_indentation(line, indentation) ⇒ String
Insert indentation into a table renderd line
32 33 34 |
# File 'lib/tty/table/indentation.rb', line 32 def insert_indentation(line, indentation) line ? " " * indentation + line.to_s : "" end |