class TTY::Table::Orientation::Vertical

A class responsible for vertical table transformation

Public Instance Methods

slice(table) click to toggle source

Slice horizontal table data into vertical

@param [Table] table

@api public

# 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) click to toggle source

Rotate table vertically

@param [Table] table

@return [nil]

@api public

# File lib/tty/table/orientation/vertical.rb, line 16
def transform(table)
  table.rotate_vertical
end