class Terminal::Table::Row
Attributes
cells[R]
Row
cells
table[R]
Private Class Methods
new(table, array = [])
click to toggle source
Initialize with width and options.
# File lib/terminal-table/lib/terminal-table/row.rb, line 16 def initialize table, array = [] @cell_index = 0 @table = table @cells = [] array.each { |item| self << item } end
Private Instance Methods
[](index)
click to toggle source
# File lib/terminal-table/lib/terminal-table/row.rb, line 31 def [] index cells[index] end
add_cell(item)
click to toggle source
# File lib/terminal-table/lib/terminal-table/row.rb, line 23 def add_cell item options = item.is_a?(Hash) ? item : {:value => item} cell = Cell.new(options.merge(:index => @cell_index, :table => @table)) @cell_index += cell.colspan @cells << cell end
Also aliased as: <<
height()
click to toggle source
# File lib/terminal-table/lib/terminal-table/row.rb, line 35 def height cells.map { |c| c.lines.count }.max end
render()
click to toggle source
# File lib/terminal-table/lib/terminal-table/row.rb, line 44 def render y = @table.style.border_y (0...height).to_a.map do |line| y + cells.map do |cell| cell.render(line) end.join(y) + y end.join("\n") end
wrap_cell(index, width)
click to toggle source
# File lib/terminal-table/lib/terminal-table/row.rb, line 39 def wrap_cell(index, width) return if @cells.nil? or @cells[index].nil? @cells[index].wrap(width) end