Class: Packetman::Table

Inherits:
Object
  • Object
show all
Includes:
ConfigMethods
Defined in:
lib/packetman/table.rb

Instance Method Summary collapse

Methods included from ConfigMethods

#config, included, #protocols

Constructor Details

#initializeTable

Returns a new instance of Table.



7
8
9
10
# File 'lib/packetman/table.rb', line 7

def initialize

  @term_table = Terminal::Table.new(headings: headings, rows: rows, style: style)
end

Instance Method Details

#headingsObject



12
13
14
# File 'lib/packetman/table.rb', line 12

def headings
  [*0..31].map{ |c| "%02d" % c }
end

#rowsObject



16
17
18
# File 'lib/packetman/table.rb', line 16

def rows
  protocols[config.transport]['table']
end

#styleObject



20
21
22
# File 'lib/packetman/table.rb', line 20

def style
  { alignment: :center, padding_left: 0, padding_right: 0}
end

#to_sObject



24
25
26
# File 'lib/packetman/table.rb', line 24

def to_s
  @term_table.to_s
end