Created
January 16, 2022 16:54
-
-
Save boof/26f721d513c79593f2db50c839d21734 to your computer and use it in GitHub Desktop.
Calculates and displays card position in a 9 pocket page
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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