Class: TTY::Table::Indentation
- Inherits:
-
Object
- Object
- TTY::Table::Indentation
- Defined in:
- lib/tty/table/indentation.rb
Overview
A class responsible for indenting table representation
Instance Attribute Summary collapse
-
#renderer ⇒ Object
readonly
Returns the value of attribute renderer.
Instance Method Summary collapse
-
#indentation ⇒ Object
Create indentation.
-
#initialize(renderer) ⇒ Indentation
constructor
Initialize an Indentation.
-
#insert_indent(part) ⇒ Object
Return a table part with indentation inserted.
Constructor Details
#initialize(renderer) ⇒ Indentation
Initialize an Indentation
13 14 15 |
# File 'lib/tty/table/indentation.rb', line 13 def initialize(renderer) @renderer = renderer end |
Instance Attribute Details
#renderer ⇒ Object (readonly)
Returns the value of attribute renderer.
8 9 10 |
# File 'lib/tty/table/indentation.rb', line 8 def renderer @renderer end |
Instance Method Details
#indentation ⇒ Object
Create indentation
20 21 22 |
# File 'lib/tty/table/indentation.rb', line 20 def indentation ' ' * renderer.indent end |
#insert_indent(part) ⇒ Object
Return a table part with indentation inserted
30 31 32 33 34 35 36 |
# File 'lib/tty/table/indentation.rb', line 30 def insert_indent(part) if part.respond_to?(:to_a) part.map { |line| insert_indentation(line) } else insert_indentation(part) end end |