Class: TTY::Table::Orientation::Vertical
- Inherits:
-
TTY::Table::Orientation
- Object
- TTY::Table::Orientation
- TTY::Table::Orientation::Vertical
- Defined in:
- lib/tty/table/orientation/vertical.rb
Overview
A class responsible for vertical table transformation
Instance Attribute Summary
Attributes inherited from TTY::Table::Orientation
Instance Method Summary collapse
-
#slice(table) ⇒ Object
Slice horizontal table data into vertical.
-
#transform(table) ⇒ nil
Rotate table vertically.
Methods inherited from TTY::Table::Orientation
coerce, #horizontal?, #initialize, #vertical?
Constructor Details
This class inherits a constructor from TTY::Table::Orientation
Instance Method Details
#slice(table) ⇒ Object
Slice horizontal table data into vertical
25 26 27 28 29 30 31 32 33 34 |
# File 'lib/tty/table/orientation/vertical.rb', line 25 def slice(table) header = table.header rows_size = table.rows_size head = header ? header : (0..rows_size).map { |n| (n + 1).to_s } (0...rows_size).reduce([]) do |array, index| array + head.zip(table.rows[index]).map { |row| table.to_row(row) } end end |
#transform(table) ⇒ nil
Rotate table vertically
16 17 18 |
# File 'lib/tty/table/orientation/vertical.rb', line 16 def transform(table) table.rotate_vertical end |