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

Returns a new instance of Printer.

Parameters:



248
249
250
251
252
# File 'lib/term_utils/tab.rb', line 248

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

Instance Attribute Details

#ioIO

Returns:

  • (IO)


242
243
244
# File 'lib/term_utils/tab.rb', line 242

def io
  @io
end

#optionsHash

Returns:

  • (Hash)


244
245
246
# File 'lib/term_utils/tab.rb', line 244

def options
  @options
end

#tableTab::Table

Returns:



240
241
242
# File 'lib/term_utils/tab.rb', line 240

def table
  @table
end

Instance Method Details

#data(values, opts = {}) ⇒ Object



259
260
261
# File 'lib/term_utils/tab.rb', line 259

def data(values, opts = {})
  @table.print_data(@io, values, @options.merge(opts))
end

#header(values = nil, opts = {}) ⇒ Object



256
257
258
# File 'lib/term_utils/tab.rb', line 256

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

#lineObject



253
254
255
# File 'lib/term_utils/tab.rb', line 253

def line
  @io.puts ""
end

#separator(opts = {}) ⇒ nil

Prints a separator.

Parameters:

  • opts (Hash) (defaults to: {})

Options Hash (opts):

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

Returns:

  • (nil)


267
268
269
# File 'lib/term_utils/tab.rb', line 267

def separator(opts = {})
  @table.print_separator(@io, @options.merge(opts))
end