check number of fields before trying to add row

git-svn-id: file:///home/svn/framework3/trunk@10482 4d416f70-5f16-0410-b530-b9f4589650da
This commit is contained in:
Joshua Drake 2010-09-26 04:16:18 +00:00
parent 01f8d6b4f6
commit e646176db7
1 changed files with 3 additions and 0 deletions

View File

@ -139,6 +139,9 @@ class Table
# Adds a row with the supplied fields.
#
def add_row(fields = [])
if fields.length != self.columns.length
raise RuntimeError, 'Invalid number of columns!'
end
fields.each_with_index { |field, idx|
if (colprops[idx]['MaxWidth'] < field.to_s.length)
colprops[idx]['MaxWidth'] = field.to_s.length