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:



235
236
237
238
239
# File 'lib/term_utils/tab.rb', line 235

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

Instance Attribute Details

#ioIO

Returns:

  • (IO)


229
230
231
# File 'lib/term_utils/tab.rb', line 229

def io
  @io
end

#optionsHash

Returns:

  • (Hash)


231
232
233
# File 'lib/term_utils/tab.rb', line 231

def options
  @options
end

#tableTab::Table

Returns:



227
228
229
# File 'lib/term_utils/tab.rb', line 227

def table
  @table
end

Instance Method Details

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



246
247
248
# File 'lib/term_utils/tab.rb', line 246

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

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



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

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

#lineObject



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

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)


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

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