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
14 15 16 |
# File 'lib/tty/table/indentation.rb', line 14 def initialize(renderer) @renderer = renderer end |
Instance Attribute Details
#renderer ⇒ Object (readonly)
Returns the value of attribute renderer.
9 10 11 |
# File 'lib/tty/table/indentation.rb', line 9 def renderer @renderer end |
Instance Method Details
#indentation ⇒ Object
Create indentation
21 22 23 |
# File 'lib/tty/table/indentation.rb', line 21 def indentation ' ' * renderer.indent end |
#insert_indent(part) ⇒ Object
Return a table part with indentation inserted
31 32 33 34 35 36 37 |
# File 'lib/tty/table/indentation.rb', line 31 def insert_indent(part) if part.respond_to?(:to_a) part.map { |line| insert_indentation(line) } else insert_indentation(part) end end |