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

Version Path
ix-cli-0.0.6 bin/ix-box
ix-cli-0.0.5 bin/ix-box
ix-cli-0.0.4 bin/ix-box
ix-cli-0.0.3 bin/ix-box
ix-cli-0.0.2 bin/ix-box
ix-cli-0.0.1 bin/ix-box