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.
402 403 404 405 406 |
# File 'lib/term_utils/tab.rb', line 402 def initialize(table, io, ) @table = table @io = io @options = end |
Instance Attribute Details
#io ⇒ IO
395 396 397 |
# File 'lib/term_utils/tab.rb', line 395 def io @io end |
#options ⇒ Hash
397 398 399 |
# File 'lib/term_utils/tab.rb', line 397 def @options end |
Instance Method Details
#data(values, opts = nil) ⇒ nil
Prints a data row.
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.
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 |
#line ⇒ Object
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.
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 |