Class: TTY::Table::Orientation::Vertical

Inherits:
TTY::Table::Orientation show all
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

#name

Instance Method Summary collapse

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

Parameters:



21
22
23
24
25
26
27
28
29
30
# File 'lib/tty/table/orientation/vertical.rb', line 21

def slice(table)
  header   = table.header
  row_size = table.row_size

  head = header ? header : (0..row_size).map { |n| (n + 1).to_s }

  (0...row_size).inject([]) do |array, index|
    array + head.zip(table.rows[index]).map { |row| table.to_row(row) }
  end
end

#transform(table) ⇒ Object



12
13
14
# File 'lib/tty/table/orientation/vertical.rb', line 12

def transform(table)
  table.rotate_vertical
end