Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed the behaviour of Table when the specified width exceeds column width #30

Merged
merged 1 commit into from Apr 13, 2015

Conversation

bcandrea
Copy link
Contributor

@bcandrea bcandrea commented Mar 4, 2013

This should fix issues/23.

@bcandrea
Copy link
Contributor Author

bcandrea commented Aug 9, 2013

If you don't care about the overall table width, having fields with unknown length should be already handled by the default behaviour of the Table object. On the other hand, if you still want the table to have a fixed width, I guess the only option is to either throw an Error or add a style modifier to truncate the contents artificially:

rows << ['Four', 'A' * 120]
table = Terminal::Table.new
table.headings = ['Word', 'Number']
table.rows = rows
table.style = {:width => 80, :truncate => true}

# > puts table
#
# +--------------------------------------+---------------------------------------+
# | Word                                 | Number                                |
# +--------------------------------------+---------------------------------------+
# | One                                  | 1                                     |
# | Two                                  | 2                                     |
# | Three                                | 3                                     |
# | Four                                 | AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA... |
# +--------------------------------------+---------------------------------------+

@jwarykowski
Copy link

Hey all, is this likely to be fixed soon?

@achanda
Copy link

achanda commented Jun 9, 2014

Can I help in merging this? We have a number of bugs depending on this.

@darrencauthon
Copy link

I came across this same issue, started to write a PR but found this. Is this to be merged?

@hakunin
Copy link

hakunin commented Feb 14, 2015

...year and a half later. whats the status on this?

@nateberkopec
Copy link
Collaborator

Thanks!

nateberkopec added a commit that referenced this pull request Apr 13, 2015
Fixed the behaviour of Table when the specified width exceeds column width
@nateberkopec nateberkopec merged commit eb34698 into tj:master Apr 13, 2015
@darrencauthon
Copy link

Thank you @nateberkopec ! 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants