Skip to content

Instantly share code, notes, and snippets.

@boof
Created January 16, 2022 16:54
Show Gist options
  • Save boof/26f721d513c79593f2db50c839d21734 to your computer and use it in GitHub Desktop.
Save boof/26f721d513c79593f2db50c839d21734 to your computer and use it in GitHub Desktop.
Calculates and displays card position in a 9 pocket page
#!/usr/bin/env ruby
DIV = %w[
╭─────┬─────┬─────╮
├─────┼─────┼─────┤
├─────┼─────┼─────┤
╰─────┴─────┴─────╯
]
ROW = "│ %3s │ %3s │ %3s │"
ARGV.each do |pos|
pos = Integer pos
page = pos / 9 + 1
rest = pos % 9
row = rest / 3
col = rest % 3
puts "PAGE #{page}:"
0.upto 2 do |y|
puts DIV[y]
if row != y then puts format(ROW, "", "", "")
elsif col == 1 then puts format(ROW, pos, "", "")
elsif col == 2 then puts format(ROW, "", pos, "")
elsif col == 3 then puts format(ROW, "", "", pos)
end
end
puts DIV[3]
puts
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment