Skip to content

Instantly share code, notes, and snippets.

@fowlmouth
Created September 8, 2011 06:26
Show Gist options
  • Save fowlmouth/1202769 to your computer and use it in GitHub Desktop.
Save fowlmouth/1202769 to your computer and use it in GitHub Desktop.
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