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.27 bin/ix-box
ix-cli-0.0.26 bin/ix-box
ix-cli-0.0.25 bin/ix-box
ix-cli-0.0.24 bin/ix-box
ix-cli-0.0.23 bin/ix-box
ix-cli-0.0.22 bin/ix-box
ix-cli-0.0.21 bin/ix-box
ix-cli-0.0.20 bin/ix-box
ix-cli-0.0.19 bin/ix-box
ix-cli-0.0.18 bin/ix-box
ix-cli-0.0.17 bin/ix-box
ix-cli-0.0.16 bin/ix-box
ix-cli-0.0.15 bin/ix-box
ix-cli-0.0.14 bin/ix-box
ix-cli-0.0.13 bin/ix-box
ix-cli-0.0.12 bin/ix-box
ix-cli-0.0.11 bin/ix-box
ix-cli-0.0.10 bin/ix-box
ix-cli-0.0.9 bin/ix-box
ix-cli-0.0.7 bin/ix-box