Class: SNMPTableViewer::Formatter::Table
- Inherits:
-
SNMPTableViewer::Formatter
- Object
- SNMPTableViewer::Formatter
- SNMPTableViewer::Formatter::Table
- Defined in:
- lib/snmp_table_viewer/formatter/table.rb
Overview
Formatting class for Table output.
Instance Method Summary collapse
-
#output(transpose: false) ⇒ String
Output the data (and headings if provided) as a table which can be displayed in the terminal.
Methods inherited from SNMPTableViewer::Formatter
Constructor Details
This class inherits a constructor from SNMPTableViewer::Formatter
Instance Method Details
#output(transpose: false) ⇒ String
Output the data (and headings if provided) as a table which can be displayed in the terminal.
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/snmp_table_viewer/formatter/table.rb', line 8 def output(transpose: false) use_headings = @headings.size > 0 data = @data if transpose # transpose the data if use_headings data = [@headings, *data].transpose use_headings = false # Don't add headings twice else data = data.transpose end end if use_headings Terminal::Table.new(rows: data, headings: @headings).to_s else Terminal::Table.new(rows: data).to_s end end |