Skip to content

Commit f14aba1

Browse files
committed
Right-align values in table
1 parent ee80186 commit f14aba1

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

lib/table_formatter.rb

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,9 @@ def build_separator(col_widths)
7070
end
7171

7272
def format_row(row, col_widths)
73-
row.map.with_index { |cell, i| cell.ljust(col_widths[i]) }
74-
.join(COLUMN_SEPARATOR)
75-
.rstrip
73+
row.map.with_index { |cell, i|
74+
i == 0 ? cell.ljust(col_widths[i]) : cell.rjust(col_widths[i])
75+
}.join(COLUMN_SEPARATOR)
76+
.rstrip
7677
end
7778
end

0 commit comments

Comments
 (0)