Created
July 4, 2025 20:07
-
-
Save Nakilon/d817e718bc989da70f3c21725f60b85d to your computer and use it in GitHub Desktop.
Revisions
-
Nakilon created this gist
Jul 4, 2025 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,6 @@ require "io/console" def table_print target = ::STDOUT sizes = transpose.map{ |col| col.map{ |_| _.to_s.size }.max } sizes.max.then{ |max| sizes.map!{ |_| [max - 1, _].min } } while sizes.sum + sizes.size >= ::IO::console.winsize[1] each{ |row| target.puts row.zip(sizes).map{ |str, size| "%-#{size}s" % ("%.#{size}s" % str) }.join(" ") } end