piotrmurach/tty

Unable to render table

fpigerre opened this issue · 2 comments

Hello!

Upon using the following line from the example listed in README.md, under section 1.2:

table.render :ascii, multiline: true

I am greeted with the following outpt:

The system cannot find the path specified.
The system cannot find the path specified.
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/tty-0.0.9/lib/tty/table/renderer/basic.rb:77:in `render': undefined method `border_class' for :ascii:Symbol (NoMethodError)
    from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/tty-0.0.9/lib/tty/support/delegatable.rb:38:in `render'
    from C:/Users/psgs/Documents/GitHub/btcl/lib/btcl.rb:107:in `<top (required)>'
    from -e:1:in `load'
    from -e:1:in `<main>'

The table I am attempting to render is initialized at the top of the page using the following line of code:

table = TTY::Table.new(header: %w['Exchange', 'Price'])

Would anybody happen to know how to ensure that the table renders correctly?
Thankyou! 🌴

Hi, sorry for late reply!

The following is one way to achieve what you need and it works:

table = TTY::Table.new %w[Exchange price], [['row1 a', 'row1 b'], ['row2 a', 'row2 b']]

puts table.render :ascii, multiline: true

There are many ways to skin a cat, and thus there are many combinations for specifying headers and columns see docs. It seems I haven't allowed for just header content - this will be fixed in future versions.

I've noticed that your version of library is 0.0.9, I would encourage you to use latest 0.1.2 with which I've tested.

On another note, as is the plan with the whole package, I will be extracting the table rendering to it's own dependency but as far as usage is concerned nothing will change, you will still need to either get tty and or use just the single dependency which I haven't extracted yet to get table rendering - no api changes as such are planned.

Hello @peter-murach,

Thankyou very much for your reply!
I have now switched to using version 0.1.2 and am displaying tables using the format you listed above.

All the best,
psgs 🌴