lib/snmp_table_viewer/formatter/table.rb
# Output the data (and headings if provided) as a table which can be displayed in the terminal.
# @param transpose [Boolean] Whether to swap rows and columns - useful for displaying a wide and short table
# @return [String] the text to display in order to draw the table
Output the data (and headings if provided) as a table which can be displayed in the terminal.
Output the data ( and headings if provided ) as a table which can be displayed in the terminal .
def output(transpose: false)
      use_headings = @headings.size > 0
      data = @data
      if transpose
        if use_headings
          data = [@headings, *data].transpose
          use_headings = false 
        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
def output ( transpose : false ) use_headings = @headings . size > 0 data = @data if transpose if use_headings data = [ @headings , * data ] . transpose use_headings = false 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
Output the data (and headings if provided) as a table which can be displayed in the terminal.
Output the data ( and headings if provided ) as a table which can be displayed in the terminal .
# transpose the data # Don't add headings twice
the text to display in order to draw the table
the text to display in order to draw the table
String
transpose
Whether to swap rows and columns - useful for displaying a wide and short table
Whether to swap rows and columns - useful for displaying a wide and short table