Class: OutputMode::Outputs::Tabulated
- Inherits:
-
OutputMode::Output
- Object
- OutputMode::Output
- OutputMode::Outputs::Tabulated
- Defined in:
- lib/output_mode/outputs/tabulated.rb
Instance Attribute Summary collapse
-
#block ⇒ #call
readonly
An optional block of code that configures the renderer.
-
#colorize ⇒ Object
readonly
Returns the value of attribute colorize.
-
#default ⇒ Object
readonly
Returns the value of attribute default.
-
#header_color ⇒ Object
readonly
An optional header color or array of colors.
-
#no ⇒ Object
readonly
Returns the value of attribute no.
-
#renderer ⇒ Symbol
readonly
The renderer type, see: github.com/piotrmurach/tty-table#32-renderer.
-
#row_color ⇒ Object
readonly
An optional data color or array of colors.
-
#yes ⇒ Object
readonly
Returns the value of attribute yes.
Attributes inherited from OutputMode::Output
Instance Method Summary collapse
-
#config ⇒ Hash
Additional options to
TTY::Table
renderer. -
#initialize(*procs, renderer: nil, **config) {|tty_table_renderer| ... } ⇒ Tabulated
constructor
A new instance of Tabulated.
-
#render(*data) ⇒ Object
Implements the render method using
TTY::Table
.
Methods inherited from OutputMode::Output
Constructor Details
#initialize(*procs, renderer: nil, **config) {|tty_table_renderer| ... } ⇒ Tabulated
Returns a new instance of Tabulated.
54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/output_mode/outputs/tabulated.rb', line 54 def initialize(*procs, renderer: :unicode, colorize: false, header_color: nil, row_color: nil, **config, &block) @renderer = renderer @block = block @header_color = header_color @row_color = row_color @colorize = colorize super(*procs, **config) end |
Instance Attribute Details
#block ⇒ #call (readonly)
Returns an optional block of code that configures the renderer.
42 43 |
# File 'lib/output_mode/outputs/tabulated.rb', line 42 attr_reader :renderer, :default, :block, :yes, :no, :header_color, :row_color, :colorize |
#colorize ⇒ Object (readonly)
Returns the value of attribute colorize.
42 43 |
# File 'lib/output_mode/outputs/tabulated.rb', line 42 attr_reader :renderer, :default, :block, :yes, :no, :header_color, :row_color, :colorize |
#default ⇒ Object (readonly)
Returns the value of attribute default.
42 43 44 |
# File 'lib/output_mode/outputs/tabulated.rb', line 42 def default @default end |
#header_color ⇒ Object (readonly)
Returns An optional header color or array of colors.
42 43 |
# File 'lib/output_mode/outputs/tabulated.rb', line 42 attr_reader :renderer, :default, :block, :yes, :no, :header_color, :row_color, :colorize |
#no ⇒ Object (readonly)
Returns the value of attribute no.
42 43 44 |
# File 'lib/output_mode/outputs/tabulated.rb', line 42 def no @no end |
#renderer ⇒ Symbol (readonly)
Returns the renderer type, see: github.com/piotrmurach/tty-table#32-renderer.
42 43 44 |
# File 'lib/output_mode/outputs/tabulated.rb', line 42 def renderer @renderer end |
#row_color ⇒ Object (readonly)
Returns An optional data color or array of colors.
42 43 |
# File 'lib/output_mode/outputs/tabulated.rb', line 42 attr_reader :renderer, :default, :block, :yes, :no, :header_color, :row_color, :colorize |
#yes ⇒ Object (readonly)
Returns the value of attribute yes.
42 43 44 |
# File 'lib/output_mode/outputs/tabulated.rb', line 42 def yes @yes end |
Instance Method Details
#config ⇒ Hash
Returns additional options to TTY::Table
renderer.
47 |
# File 'lib/output_mode/outputs/tabulated.rb', line 47 def config; super; end |
#render(*data) ⇒ Object
Implements the render method using TTY::Table
72 73 74 75 76 |
# File 'lib/output_mode/outputs/tabulated.rb', line 72 def render(*data) table = TTY::Table.new header: processed_header data.each { |d| table << process_row(d) } table.render(renderer, **config, &block) || '' end |