Retab changes for PR #2093

bug/bundler_fix
Tab Assassin 2013-09-05 14:31:10 -05:00
parent 8a76b3390d
commit 81479a6ade
2 changed files with 1918 additions and 1918 deletions

File diff suppressed because it is too large Load Diff

View File

@ -222,96 +222,96 @@ class Table
protected protected
# #
# Defaults cell widths and alignments. # Defaults cell widths and alignments.
# #
def defaults # :nodoc: def defaults # :nodoc:
self.columns.length.times { |idx| self.columns.length.times { |idx|
} }
end end
# #
# Checks to see if the row is an hr. # Checks to see if the row is an hr.
# #
def is_hr(row) # :nodoc: def is_hr(row) # :nodoc:
return ((row.kind_of?(String)) && (row == '__hr__')) return ((row.kind_of?(String)) && (row == '__hr__'))
end end
# #
# Converts the columns to a string. # Converts the columns to a string.
# #
def columns_to_s # :nodoc: def columns_to_s # :nodoc:
nameline = ' ' * indent nameline = ' ' * indent
barline = nameline.dup barline = nameline.dup
last_col = nil last_col = nil
last_idx = nil last_idx = nil
columns.each_with_index { |col,idx| columns.each_with_index { |col,idx|
if (last_col) if (last_col)
nameline << pad(' ', last_col, last_idx) nameline << pad(' ', last_col, last_idx)
remainder = colprops[last_idx]['MaxWidth'] - last_col.length remainder = colprops[last_idx]['MaxWidth'] - last_col.length
if (remainder < 0) if (remainder < 0)
remainder = 0 remainder = 0
end end
barline << (' ' * (cellpad + remainder)) barline << (' ' * (cellpad + remainder))
end end
nameline << col nameline << col
barline << ('-' * col.length) barline << ('-' * col.length)
last_col = col last_col = col
last_idx = idx last_idx = idx
} }
return "#{nameline}\n#{barline}" return "#{nameline}\n#{barline}"
end end
# #
# Converts an hr to a string. # Converts an hr to a string.
# #
def hr_to_s # :nodoc: def hr_to_s # :nodoc:
return "\n" return "\n"
end end
# #
# Converts a row to a string. # Converts a row to a string.
# #
def row_to_s(row) # :nodoc: def row_to_s(row) # :nodoc:
line = ' ' * indent line = ' ' * indent
last_cell = nil last_cell = nil
last_idx = nil last_idx = nil
row.each_with_index { |cell, idx| row.each_with_index { |cell, idx|
if (last_cell) if (last_cell)
line << pad(' ', last_cell.to_s, last_idx) line << pad(' ', last_cell.to_s, last_idx)
end end
# line << pad(' ', cell.to_s, idx) # line << pad(' ', cell.to_s, idx)
# Limit wide cells # Limit wide cells
if colprops[idx]['MaxChar'] if colprops[idx]['MaxChar']
last_cell = cell.to_s[0..colprops[idx]['MaxChar'].to_i] last_cell = cell.to_s[0..colprops[idx]['MaxChar'].to_i]
line << last_cell line << last_cell
else else
line << cell.to_s line << cell.to_s
last_cell = cell last_cell = cell
end end
last_idx = idx last_idx = idx
} }
return line + "\n" return line + "\n"
end end
# #
# Pads out with the supplied character for the remainder of the space given # Pads out with the supplied character for the remainder of the space given
# some text and a column index. # some text and a column index.
# #
def pad(chr, buf, colidx, use_cell_pad = true) # :nodoc: def pad(chr, buf, colidx, use_cell_pad = true) # :nodoc:
remainder = colprops[colidx]['MaxWidth'] - buf.length remainder = colprops[colidx]['MaxWidth'] - buf.length
val = chr * remainder; val = chr * remainder;
if (use_cell_pad) if (use_cell_pad)
val << ' ' * cellpad val << ' ' * cellpad
end end
return val return val
end end
end end