Class: Bmg::Writer::Text::Row
- Inherits:
-
Object
- Object
- Bmg::Writer::Text::Row
- Includes:
- Utils
- Defined in:
- lib/bmg/writer/text.rb
Overview
class Cell
Instance Method Summary collapse
-
#initialize(renderer, values) ⇒ Row
constructor
A new instance of Row.
- #min_widths ⇒ Object
- #rendering_lines(sizes = min_widths) ⇒ Object
Methods included from Utils
Constructor Details
Instance Method Details
#min_widths ⇒ Object
89 90 91 |
# File 'lib/bmg/writer/text.rb', line 89 def min_widths @cells.map{|cell| cell.min_width} end |
#rendering_lines(sizes = min_widths) ⇒ Object
93 94 95 96 97 98 99 100 101 102 103 104 105 106 |
# File 'lib/bmg/writer/text.rb', line 93 def rendering_lines(sizes = min_widths) nb_lines = 0 by_cell = @cells.zip(sizes).map do |cell,size| lines = cell.rendering_lines(size) nb_lines = max(nb_lines, lines.size) lines end grid = (0...nb_lines).map do |line_i| "| " + by_cell.zip(sizes).map{|cell_lines, size| cell_lines[line_i] || " "*size }.join(" | ") + " |" end grid.empty? ? ["| |"] : grid end |