-
-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathqrcode-aa
More file actions
executable file
·31 lines (27 loc) · 711 Bytes
/
Copy pathqrcode-aa
File metadata and controls
executable file
·31 lines (27 loc) · 711 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#!/usr/bin/env ruby
##
## Print QR Code by ASCII-Art
## Copyright (c) 2013 SATOH Fumiyasu @ OSS Technology Corp., Japan
##
## License: GNU General Public License version 3
##
## See also:
## QR code generator for terminals (ASCII art, Sixel)
## https://github.com/fumiyas/qrc
require "rqrcode"
qrc = RQRCode::QRCode.new(ARGV.size == 0 ? $stdin.readline.chomp : ARGV[0], :size=>1, :level=>:l)
t_reset = `tput sgr0`
t_white = `tput setab 7` + ' ' + t_reset
t_black = `tput setab 0` + ' ' + t_reset
puts qrc.
to_s.
gsub(/(^|$)/, ' ').
sub(/\A.*$/) {|m|
m.gsub(/./, ' ') + "\n" + m
}.
sub(/^.*\Z/) {|m|
m + "\n" + m.gsub(/./, ' ')
}.
gsub(' ', t_white).
gsub('x', t_black)
exit(0)