Class: TTY::Table::Renderer::Basic
- Inherits:
-
Object
- Object
- TTY::Table::Renderer::Basic
- Extended by:
- Delegatable
- Defined in:
- lib/tty/table/renderer/basic.rb
Overview
Renders table without any border styles.
Constant Summary collapse
- TABLE_DELEGATED_METHODS =
[:column_widths, :alignments]
Instance Attribute Summary collapse
-
#border_class ⇒ TTY::Table::Border
readonly
private
Table border to be rendered.
- #indent ⇒ Object readonly
- #padding ⇒ Object
-
#table ⇒ TTY::Table
readonly
Table to be rendered.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Table::Renderer::Basic
constructor
Initialize and setup a Renderer.
-
#render(table, border_class = Border::Null) ⇒ String
Renders table.
Methods included from Delegatable
Constructor Details
#initialize(options = {}) ⇒ Table::Renderer::Basic
Initialize and setup a Renderer
49 50 51 |
# File 'lib/tty/table/renderer/basic.rb', line 49 def initialize(={}) setup() end |
Instance Attribute Details
#border_class ⇒ TTY::Table::Border (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Table border to be rendered
28 29 30 |
# File 'lib/tty/table/renderer/basic.rb', line 28 def border_class @border_class end |
#indent ⇒ Object (readonly)
13 14 15 |
# File 'lib/tty/table/renderer/basic.rb', line 13 def indent @indent end |
#padding ⇒ Object
11 12 13 |
# File 'lib/tty/table/renderer/basic.rb', line 11 def padding @padding end |
#table ⇒ TTY::Table (readonly)
Table to be rendered
20 21 22 |
# File 'lib/tty/table/renderer/basic.rb', line 20 def table @table end |
Class Method Details
.render(table, options = {}) ⇒ Object
76 77 78 |
# File 'lib/tty/table/renderer/basic.rb', line 76 def self.render(table, ={}) new().render(table) end |
Instance Method Details
#render(table, border_class = Border::Null) ⇒ String
Renders table
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 |
# File 'lib/tty/table/renderer/basic.rb', line 88 def render(table, border_class=Border::Null) @table = table @border_class = border_class return if table.to_a.empty? # setup(options) body = [] unless table.length.zero? ColumnSet.new(table).extract_widths! # TODO: throw an error if too many columns as compared to terminal width # and then change table.orientation from vertical to horizontal # TODO: Decide about table orientation body += render_header body += render_rows end body.compact.join("\n") end |