class TermUtils::Tab::Printer

Represents a table printer.

Attributes

io[RW]

@return [IO]

options[RW]

@return [Hash]

table[RW]

@return [Tab::Table]

Public Class Methods

new(table, io, options) click to toggle source

@param table [Tab::Table] @param io [IO] @param options [Hash]

# File lib/term_utils/tab.rb, line 402
def initialize(table, io, options)
  @table = table
  @io = io
  @options = options
end

Public Instance Methods

data(values, opts = nil) click to toggle source

Prints a data row. @param values [Array<Object>, Hash<Symbol, Object>] @param opts [Hash] @option opts [Integer] :offset @option opts [Integer] :column_separator_width @return [nil]

# 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) click to toggle source

Prints a header row. @param values [Array<Object>, Hash<Symbol, Object>] @param opts [Hash] @option opts [Integer] :offset @option opts [Integer] :column_separator_width @return [nil]

# 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
line() click to toggle source

Prints an empty line.

# File lib/term_utils/tab.rb, line 409
def line
  @io.puts
end
separator(opts = nil) click to toggle source

Prints a separator. @param opts [Hash] @option opts [Integer] :offset @option opts [Integer] :column_separator_width @return [nil]

# File lib/term_utils/tab.rb, line 438
def separator(opts = nil)
  @table.print_separator(@io, opts ? @options.merge(opts) : @options)
end