Sha256: 107d3be77698d3f11c7ca5e95f604ed20f6d4ff0d1a6fbf8d4ec69d2408ba39f
Contents?: true
Size: 633 Bytes
Versions: 26
Compression:
Stored size: 633 Bytes
Contents
#!/usr/bin/env ruby def boxify(string) join = '+' frame = '-' wall = '|' width = 0 height = 0 string.each_line do |line| if line.size > width width = line.chomp.size end height += 1 end puts "#{join}#{frame}#{frame * width}#{frame}#{join}" string.each_line do |line| puts "#{wall} #{line.chomp}#{' ' * (width - line.chomp.size)} #{wall}" end puts "#{join}#{frame}#{frame * width}#{frame}#{join}" end box = ARGV[0] == '-b' if box text = '' STDIN.each_line do |line| text << line end boxify(text) else STDIN.each_line do |line| boxify(line.chomp) end end
Version data entries
26 entries across 26 versions & 1 rubygems