Class: TermUtils::Tab::Printer

Inherits:
Object
  • Object
show all
Defined in:
lib/term_utils/tab.rb

Overview

Represents a table printer.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(table, io, options) ⇒ Printer



402
403
404
405
406
# File 'lib/term_utils/tab.rb', line 402

def initialize(table, io, options)
  @table = table
  @io = io
  @options = options
end

Instance Attribute Details

#ioIO



395
396
397
# File 'lib/term_utils/tab.rb', line 395

def io
  @io
end

#optionsHash



397
398
399
# File 'lib/term_utils/tab.rb', line 397

def options
  @options
end

#tableTab::Table



393
394
395
# File 'lib/term_utils/tab.rb', line 393

def table
  @table
end

Instance Method Details

#data(values, opts = nil) ⇒ nil

Prints a data row.

Options Hash (opts):

  • :offset (Integer)
  • :column_separator_width (Integer)


429
430
431
# File 'lib/term_utils/tab.rb', line 429

def data(values, opts = nil)
  @table.print_data(@io, values, opts ? @options.merge(opts) : @options)
end

#header(values = nil, opts = nil) ⇒ nil

Prints a header row.

Options Hash (opts):

  • :offset (Integer)
  • :column_separator_width (Integer)


419
420
421
# File 'lib/term_utils/tab.rb', line 419

def header(values = nil, opts = nil)
  @table.print_header(@io, values, opts ? @options.merge(opts) : @options)
end

#lineObject

Prints an empty line.



409
410
411
# File 'lib/term_utils/tab.rb', line 409

def line
  @io.puts
end

#separator(opts = nil) ⇒ nil

Prints a separator.

Options Hash (opts):

  • :offset (Integer)
  • :column_separator_width (Integer)


438
439
440
# File 'lib/term_utils/tab.rb', line 438

def separator(opts = nil)
  @table.print_separator(@io, opts ? @options.merge(opts) : @options)
end