piotrmurach/tty

Cannot align individual fields

wwboynton opened this issue · 6 comments

Hello!

When I take a rows set with a single row like this:

rows = [['swag', 'derp', 'foo', 'bar']]

And render a new table with it, it works just swimmingly.

However, when I amend one of those with the syntax specified in the alignment section of the documentation...

rows = [['swag', 'derp', {:value => 'foo', :align => :right}, 'bar']]

...there is no change reflected in the table. The alignment of the selected cell does not change.

This remains true when attempting to align to the center, as well. Any help would be much appreciated.

Thanks!

On closer inspection, any attempt to right-align any amount of anything either does not work, or raises an error.

An attempt to align the column using

column_aligns: [:right, :right, :right, :right]

at render time yields no change in table either.

More interestingly, an attempt to call

table.align_column(3, :right)

on my new table actually raises an error:

undefined method `align_column' for #<TTY::Table:0x007fb2bfa43228>

On inspection, this method certainly does not exist, except in the documentation.

Thanks for using the library.

I will look into this - thanks for reporting.

On another note, I'm currently working on extracting table rendering to its own dependency. So in future you will be able to just use the dependency. I will let you know when this is done as well, so we can continue any future conversation there.

That sounds like an excellent idea. TTY has been a tremendous asset to my development, and I look forward to seeing its future.

@wwboynton This is fixed in master branch - see tty-table . I have changed the api ever so slightly to be more intuitive and less verbose - see alignment. Looking forward to your feedback if you have a minute to try it out!

There are few other bits of documentation and code that I need to go over before I can look into rendering coloured content.

I noticed your update when you closed the issue. Assuming all works as it should, I look forward to using it this coming week! Thanks again for the continued development of such a valuable gem.

In your testing if you find anything broken/wish-it-was-there please post an issue on tty-table. I have already found your comments very helpful in fixing/shaping up the api.