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

Strange separator inserting #31

Open
foxweb opened this issue Apr 28, 2020 · 0 comments
Open

Strange separator inserting #31

foxweb opened this issue Apr 28, 2020 · 0 comments
Labels

Comments

@foxweb
Copy link

foxweb commented Apr 28, 2020

I want to separate rows by differ type. portfolio_table << :separator is not working properly inside each-block.

portfolio_table << :separator << row_data(item) is not working properly also.

Steps to reproduce the problem

def portfolio_table
  @portfolio_table ||= TTY::Table.new(
    header: %w[Type Name Amount Avg.\ price Yield Yield\ %]
  )
end

prev_type = positions.first[:instrumentType]

positions.each do |item|
  portfolio_table << :separator if item[:instrumentType] != prev_type
  portfolio_table << row_data(item)
  prev_type = item[:instrumentType]
end

puts portfolio_table.render(:ascii, padding: [0, 1, 0, 1])

Actual behaviour

+---------
| Type    
| STOCK   
| STOCK   
| STOCK   
| STOCK   
| STOCK   
| STOCK   
+---------
| STOCK   
| STOCK   
| STOCK   
| STOCK   
| STOCK   
| STOCK   
| STOCK   
| STOCK   
| STOCK   
| STOCK   
| STOCK   
| BOND    
| ETF     
| ETF     
| ETF     
| ETF     
| ETF     
| ETF     
| CURRENCY
| CURRENCY
+----------

Expected behaviour

Type
------
Stock
Stock
Stock
Stock
Stock
Stock
Stock
Stock
Stock
Stock
Stock
Stock
Stock
Stock
Stock
Stock
Stock
------
Bond
------
Etf
Etf
Etf
Etf
Etf
Etf
------
Currency
Currency

Environment

  • OS version: macOS Catalina
  • Ruby version: 2.7.1
  • TTY::Table version: tty-table (0.11.0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants