Class: TermUtils::Tab::Printer
- Inherits:
-
Object
- Object
- TermUtils::Tab::Printer
- Defined in:
- lib/term_utils/tab.rb
Overview
Represents a table printer.
Instance Attribute Summary collapse
Instance Method Summary collapse
-
#data(values, opts = nil) ⇒ nil
Prints a data row.
-
#header(values = nil, opts = nil) ⇒ nil
Prints a header row.
-
#initialize(table, io, options) ⇒ Printer
constructor
A new instance of Printer.
-
#line ⇒ Object
Prints an empty line.
-
#separator(opts = nil) ⇒ nil
Prints a separator.
Constructor Details
#initialize(table, io, options) ⇒ Printer
Returns a new instance of Printer.
377 378 379 380 381 |
# File 'lib/term_utils/tab.rb', line 377 def initialize(table, io, ) @table = table @io = io @options = end |
Instance Attribute Details
#io ⇒ IO
371 372 373 |
# File 'lib/term_utils/tab.rb', line 371 def io @io end |
#options ⇒ Hash
373 374 375 |
# File 'lib/term_utils/tab.rb', line 373 def @options end |
Instance Method Details
#data(values, opts = nil) ⇒ nil
Prints a data row.
401 402 403 |
# File 'lib/term_utils/tab.rb', line 401 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.
392 393 394 |
# File 'lib/term_utils/tab.rb', line 392 def header(values = nil, opts = nil) @table.print_header(@io, values, opts ? @options.merge(opts) : @options) end |
#line ⇒ Object
Prints an empty line.
383 384 385 |
# File 'lib/term_utils/tab.rb', line 383 def line @io.puts "" end |
#separator(opts = nil) ⇒ nil
Prints a separator.
409 410 411 |
# File 'lib/term_utils/tab.rb', line 409 def separator(opts = nil) @table.print_separator(@io, opts ? @options.merge(opts) : @options) end |