Class Terminal::Table::Row
In: lib/terminal-table/row.rb
lib/terminal-table/row.rb
Parent: Object

Methods

<<   <<   []   []   add_cell   add_cell   height   height   new   new   render   render  

Attributes

cells  [R]  Row cells
cells  [R]  Row cells
table  [R] 
table  [R] 

Public Class methods

Initialize with width and options.

[Source]

    # File lib/terminal-table/row.rb, line 15
15:       def initialize table, array = []
16:         @cell_index = 0
17:         @table = table
18:         @cells = []
19:         array.each { |item| self << item }
20:       end

Initialize with width and options.

[Source]

    # File lib/terminal-table/row.rb, line 15
15:       def initialize table, array = []
16:         @cell_index = 0
17:         @table = table
18:         @cells = []
19:         array.each { |item| self << item }
20:       end

Public Instance methods

<<(item)

Alias for add_cell

<<(item)

Alias for add_cell

[Source]

    # File lib/terminal-table/row.rb, line 30
30:       def [] index
31:         cells[index]
32:       end

[Source]

    # File lib/terminal-table/row.rb, line 30
30:       def [] index
31:         cells[index]
32:       end

[Source]

    # File lib/terminal-table/row.rb, line 22
22:       def add_cell item
23:         options = item.is_a?(Hash) ? item : {:value => item}
24:         cell = Cell.new(options.merge(:index => @cell_index, :table => @table))
25:         @cell_index += cell.colspan
26:         @cells << cell
27:       end

[Source]

    # File lib/terminal-table/row.rb, line 22
22:       def add_cell item
23:         options = item.is_a?(Hash) ? item : {:value => item}
24:         cell = Cell.new(options.merge(:index => @cell_index, :table => @table))
25:         @cell_index += cell.colspan
26:         @cells << cell
27:       end

[Source]

    # File lib/terminal-table/row.rb, line 34
34:       def height
35:         cells.map { |c| c.lines.count }.max
36:       end

[Source]

    # File lib/terminal-table/row.rb, line 34
34:       def height
35:         cells.map { |c| c.lines.count }.max
36:       end

[Source]

    # File lib/terminal-table/row.rb, line 38
38:       def render
39:         y = @table.style.border_y
40:         (0...height).to_a.map do |line|
41:           y + cells.map do |cell|
42:             cell.render(line)
43:           end.join(y) + y
44:         end.join("\n")
45:       end

[Source]

    # File lib/terminal-table/row.rb, line 38
38:       def render
39:         y = @table.style.border_y
40:         (0...height).to_a.map do |line|
41:           y + cells.map do |cell|
42:             cell.render(line)
43:           end.join(y) + y
44:         end.join("\n")
45:       end

[Validate]