Created
September 8, 2011 06:26
-
-
Save fowlmouth/1202769 to your computer and use it in GitHub Desktop.
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 characters
def columnize list, cols = 3, width = ENV['COLUMNS'].to_i | |
list.size.times { |i| | |
next if i%cols != 0 | |
cols.times { |x| | |
break unless list[i+x] | |
print list[i+x][0,width/cols].ljust(width/cols) | |
} | |
puts | |
} | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment