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

:colspan creates conflicts with colorize #95

Closed
FluffyCode opened this issue Nov 14, 2017 · 1 comment
Closed

:colspan creates conflicts with colorize #95

FluffyCode opened this issue Nov 14, 2017 · 1 comment

Comments

@FluffyCode
Copy link

(Say that title ten times fast...)

Using terminal-table has been fantastic for me, particularly due to its compatibility with colorize. I even combine colors with :border_x, :border_y and :border_i to create custom-colored tables/borders.

However I got around to experimenting with :colspan to split the display of "cell" data, and colorize ends up breaking :border_y.

table_sc

The tables turn out as such:

table_result

Of course, I can remove the :border_y styling to fix it...

table_result2

...but then I don't have my schnazzy blue dividers.

Capy-pasta-able code, in case you'd like to experiment:

require 'colorize'
require 'terminal-table'

original_sample_data = [
["Sep 2016", 33, [-38, -53.52], 46, [-25, -35.21]],
["Oct 2016", 35, [2, 6.06], 50, [4, 8.69]]
]

table = Terminal::Table.new headings: ["Month".cyan,"Monthly IT".cyan,"IT Difference OPM".cyan,
"Monthly OOT".cyan,"OOT Difference OPM".cyan], rows: original_sample_data

table.style = { padding_left: 2, padding_right: 2, border_x: "-".blue, border_y: "|".blue, border_i: "+".blue }

puts table

puts ""
puts "^ good table"
puts "v wonky talbe"
puts ""

split_column_sample_data = [
["Sep 2016", 33, -38, -53.52, 46, -25, -35.21],
["Oct 2016", 35, 2, 6.06, 50, 4, 8.69]
]

table = Terminal::Table.new headings: ["Month".cyan,"Monthly IT".cyan,
{value: "IT Difference OPM".cyan, colspan: 2}, "Monthly OOT".cyan,
{value: "OOT Difference OPM".cyan, colspan: 2}], rows: split_column_sample_data

table.style = { padding_left: 2, padding_right: 2, border_x: "-".blue, border_y: "|".blue, border_i: "+".blue }

puts table

@nanobowers
Copy link
Contributor

@nateberkopec I think this can be closed - bug fixed as part of #113

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

No branches or pull requests

3 participants