Method: Terminal::Table#initialize

Defined in:
lib/terminal-table/table.rb

#initialize(options = {}, &block) ⇒ Table

Generates a ASCII/Unicode table with the given options.



12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/terminal-table/table.rb', line 12

def initialize options = {}, &block
  @elaborated = false
  @headings = []
  @rows = []
  @column_widths = []
  self.style = options.fetch :style, {}
  self.headings = options.fetch :headings, []
  self.rows = options.fetch :rows, []
  self.title = options.fetch :title, nil
  yield_or_eval(&block) if block

  style.on_change(:width) { require_column_widths_recalc }
end