Skip to content

Commit

Permalink
Merge pull request #75 from vizv/fix-colspan-column-selection
Browse files Browse the repository at this point in the history
Fix column selection with colspan option.
  • Loading branch information
nateberkopec authored Aug 28, 2016
2 parents 64f8823 + 62e914d commit c14b98f
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion lib/terminal-table/table.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,15 @@ def cell_padding

def column n, method = :value, array = rows
array.map { |row|
cell = row[n]
# for each cells in a row, find the column with index
# just greater than the required one, and go back one.
index = col = 0
row.cells.each do |cell|
break if index > n
index += cell.colspan
col += 1
end
cell = row[col - 1]
cell && method ? cell.__send__(method) : cell
}.compact
end
Expand Down

0 comments on commit c14b98f

Please sign in to comment.