Class: Msf::Ui::Console::Table

Inherits:
Rex::Ui::Text::Table show all
Defined in:
lib/msf/ui/console/table.rb

Overview

Console table display wrapper that allows for stylized tables

Defined Under Namespace

Modules: Style

Instance Attribute Summary

Attributes inherited from Rex::Ui::Text::Table

#cellpad, #colprops, #columns, #header, #headeri, #indent, #postfix, #prefix, #rows, #sort_index, #width

Instance Method Summary collapse

Methods inherited from Rex::Ui::Text::Table

#<<, #[], #add_hr, #add_row, #header_to_s, #print, #sort_rows, #to_csv

Constructor Details

#initialize(style, opts = {}) ⇒ Table

Initializes a wrappered table with the supplied style and options.


24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/msf/ui/console/table.rb', line 24

def initialize(style, opts = {})
  self.style = style

  if (self.style == Style::Default)
    opts['Indent']  = 3
    if (!opts['Prefix'])
      opts['Prefix']  = "\n"
    end
    if (!opts['Postfix'])
      opts['Postfix'] = "\n"
    end

    super(opts)
  end
end

Instance Method Details

#to_sObject

Print nothing if there are no rows if the style is default.


43
44
45
46
47
48
49
# File 'lib/msf/ui/console/table.rb', line 43

def to_s
  if (style == Style::Default)
    return '' if (rows.length == 0)
  end

  super
end